初版网页

This commit is contained in:
2026-08-10 21:05:36 +08:00
parent cfc0849081
commit f50e9f7c1e
19 changed files with 1697 additions and 16 deletions
+29
View File
@@ -0,0 +1,29 @@
#include "Web_Server.h"
#include <charconv>
#include <cstdint>
#include <iostream>
#include <string_view>
namespace {
std::uint16_t parse_port(int argc, char** argv) {
constexpr std::uint16_t default_port = 8848;
if (argc != 3 || std::string_view(argv[1]) != "--port")
return default_port;
unsigned value{};
const std::string_view text(argv[2]);
const auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), value);
if (error != std::errc{} || end != text.data() + text.size() || value == 0 || value > 65535) {
std::cerr << "Invalid port: " << text << '\n';
return 0;
}
return static_cast<std::uint16_t>(value);
}
} // namespace
int main(int argc, char** argv) {
const std::uint16_t port = parse_port(argc, argv);
return port == 0 ? 2 : renderive::web::run_web_server(port);
}