.
This commit is contained in:
15
src/main.cpp
15
src/main.cpp
@@ -4,16 +4,17 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
if (argc != 2) {
|
std::filesystem::path config_path = std::filesystem::path(std::getenv("HOME")) / ".config/dropshell_template_registry/config.json";
|
||||||
std::cerr << "Usage: " << argv[0] << " <config_file>" << std::endl;
|
std::filesystem::create_directories(config_path.parent_path());
|
||||||
|
|
||||||
|
dropshell::ServerConfig config;
|
||||||
|
if (!dropshell::load_config(config_path, config)) {
|
||||||
|
std::cerr << "Failed to load configuration at "<<config_path << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dropshell::ServerConfig config;
|
std::cout << "Starting server at " << config.host << ":" << config.port << std::endl;
|
||||||
if (!dropshell::load_config(argv[1], config)) {
|
std::cout << "Object store path: " << config.object_store_path << std::endl;
|
||||||
std::cerr << "Failed to load configuration" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dropshell::Server server(config);
|
dropshell::Server server(config);
|
||||||
if (!server.start()) {
|
if (!server.start()) {
|
||||||
|
@@ -107,7 +107,7 @@ void Server::handle_connection(int client_socket) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path == "/index.html") {
|
if (path == "/index.html" || path == "/") {
|
||||||
send_response(client_socket, 200, "text/html",
|
send_response(client_socket, 200, "text/html",
|
||||||
"<html><body><h1>Dropshell Template Registry</h1></body></html>");
|
"<html><body><h1>Dropshell Template Registry</h1></body></html>");
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user