Added basic diplay endpoint. Added images folder.

This commit is contained in:
2026-06-23 15:31:35 +03:00
parent 23e2fbd995
commit 2e7899c701
2 changed files with 29 additions and 4 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
server server
*.json *.json
images/*

View File

@@ -48,6 +48,7 @@ int main(int argc, char **argv)
json_extract(cfg, "devices_filename", devices_filename); json_extract(cfg, "devices_filename", devices_filename);
json_extract(cfg, "host", host); json_extract(cfg, "host", host);
json_extract(cfg, "port", port); json_extract(cfg, "port", port);
json_extract(cfg, "folder_images", folder_images);
// json_extract(cfg, "cert_file", cert_file); // json_extract(cfg, "cert_file", cert_file);
// json_extract(cfg, "key_file", cert_file); // json_extract(cfg, "key_file", cert_file);
@@ -63,6 +64,12 @@ int main(int argc, char **argv)
return -1; return -1;
} }
if (folder_images.empty())
{
cout << "folder for images is empty" << endl;
return -1;
}
if (!cert_file.empty() && !key_file.empty()) if (!cert_file.empty() && !key_file.empty())
{ {
// TODO: Implement SSL Server Properly // TODO: Implement SSL Server Properly
@@ -151,6 +158,16 @@ int main(int argc, char **argv)
} }
}; };
auto display_handler = [&container, &devices_filename](const httplib::Request& req, httplib::Response& res)
{
res.status = 500;
for (auto header : res.headers)
{
cout << header.first << ": " << header.second << endl;
}
};
auto log_handler = [](const httplib::Request& req, httplib::Response& res) auto log_handler = [](const httplib::Request& req, httplib::Response& res)
{ {
try try
@@ -165,12 +182,19 @@ int main(int argc, char **argv)
res.status = 200; res.status = 200;
}; };
server->Get("/api/setup/", setup_handler);
server->Get("/api/setup", setup_handler);
server->Post("/api/log/", log_handler); server->Get("/api/setup/*", setup_handler);
server->Post("/api/log", log_handler); server->Get("/api/display/*", display_handler);
server->Post("/api/log/*", log_handler);
ok = server->set_mount_point("/images", folder_images);
if (!ok)
{
cout << "Could not mount images folder" << endl;
return -1;
}
cout << "Server listening on " << host << ":" << port << endl;
server->listen(host, port); server->listen(host, port);
return 0; return 0;