파일 분할 코멘트 추가
This commit is contained in:
23
web_task.cpp
23
web_task.cpp
@@ -353,6 +353,29 @@ void setupWebRoutes() {
|
||||
server.streamFile(file, "text/csv");
|
||||
file.close();
|
||||
});
|
||||
|
||||
// --- Set/Update file comment ---
|
||||
server.on("/api/comment", HTTP_POST, []() {
|
||||
if (!server.hasArg("plain")) {
|
||||
server.send(400, "application/json", "{\"error\":\"no body\"}");
|
||||
return;
|
||||
}
|
||||
StaticJsonDocument<512> doc;
|
||||
DeserializationError err = deserializeJson(doc, server.arg("plain"));
|
||||
if (err) {
|
||||
server.send(400, "application/json", "{\"error\":\"invalid json\"}");
|
||||
return;
|
||||
}
|
||||
const char *fname = doc["file"];
|
||||
const char *comment = doc["comment"] | "";
|
||||
if (!fname) {
|
||||
server.send(400, "application/json", "{\"error\":\"missing file\"}");
|
||||
return;
|
||||
}
|
||||
bool ok = sdSetComment(fname, comment);
|
||||
String resp = "{\"ok\":" + String(ok ? "true" : "false") + "}";
|
||||
server.send(200, "application/json", resp);
|
||||
});
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user