删除了不使用的文件
This commit is contained in:
@@ -49,7 +49,7 @@ int main() {
|
||||
// 定义路由,处理 /api/power-data 的请求
|
||||
CROW_ROUTE(app, "/api/download-db")
|
||||
([&db]() {
|
||||
std::ifstream file("/home/zjk/project/H100/H100PowerManger/data/power_data.db", std::ios::binary);
|
||||
std::ifstream file("/home/zjk/project/H100/H100PowerManger/src/appPowerMangerWebUI/static/index.html", std::ios::binary);
|
||||
if (!file) {
|
||||
return crow::response(404, "Database file not found");
|
||||
}
|
||||
@@ -86,12 +86,39 @@ int main() {
|
||||
}
|
||||
return response;
|
||||
});
|
||||
// 定义路由,处理 /api/moos-notify 的请求(POST)
|
||||
CROW_ROUTE(app, "/api/moos-notify")
|
||||
([&moosClient]() {
|
||||
crow::json::wvalue response;
|
||||
response["message"] = "Received MOOS notification";
|
||||
return response;
|
||||
// 定义路由,处理 /api/moos-notify 的请求(POST)
|
||||
CROW_ROUTE(app, "/api/moos-notify").methods("POST"_method)
|
||||
([&moosClient](const crow::request& req) {
|
||||
auto json = crow::json::load(req.body);
|
||||
if (!json) {
|
||||
return crow::response(400, "Invalid JSON");
|
||||
}
|
||||
|
||||
std::string var = json["var"].s();
|
||||
std::string key = json["key"].s();
|
||||
|
||||
// 发送MOOS消息
|
||||
bool notifyResult = moosClient.Notify(var, key);
|
||||
std::cout << "MOOS Notify: var=" << var << ", key=" << key
|
||||
<< ", result=" << (notifyResult ? "success" : "failed") << std::endl;
|
||||
|
||||
crow::response res;
|
||||
if (notifyResult)
|
||||
{
|
||||
res.body = crow::json::wvalue({
|
||||
{"success", true},
|
||||
{"message", key + ":" + var}
|
||||
}).dump();
|
||||
}
|
||||
else
|
||||
{
|
||||
res.body = crow::json::wvalue({
|
||||
{"success", false},
|
||||
{"message", key + ":" + var},
|
||||
}).dump();
|
||||
}
|
||||
res.set_header("Content-Type", "application/json");
|
||||
return res;
|
||||
});
|
||||
|
||||
// 启动服务器,监听端口 18080
|
||||
|
||||
Reference in New Issue
Block a user