41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#include "app/lidar_manager_app.hpp"
|
|
|
|
#include "server/api_server.hpp"
|
|
#include "server/static_file_server.hpp"
|
|
#include "storage/state_repository.hpp"
|
|
|
|
#include <httplib.h>
|
|
#include <cstdio>
|
|
|
|
namespace lm {
|
|
|
|
LidarManagerApp::LidarManagerApp(int port,
|
|
std::filesystem::path www_root,
|
|
std::filesystem::path data_path)
|
|
: port_(port), www_root_(std::move(www_root)), data_path_(std::move(data_path))
|
|
{
|
|
}
|
|
|
|
int LidarManagerApp::run()
|
|
{
|
|
StateRepository repo(data_path_);
|
|
repo.load();
|
|
|
|
httplib::Server svr;
|
|
ApiServer api(repo);
|
|
api.registerRoutes(svr);
|
|
StaticFileServer::mount(svr, www_root_);
|
|
|
|
std::fprintf(stderr,
|
|
"lidar_manager_web listening on http://0.0.0.0:%d (www=%s, state=%s, models=%s)\n",
|
|
port_,
|
|
www_root_.string().c_str(),
|
|
data_path_.string().c_str(),
|
|
(data_path_.parent_path() / "models").string().c_str());
|
|
|
|
svr.listen("0.0.0.0", port_);
|
|
return 0;
|
|
}
|
|
|
|
} // namespace lm
|