summaryrefslogtreecommitdiffstats
path: root/f015_apihandler.ino
diff options
context:
space:
mode:
authorAnton L. Šijanec <sijanecantonluka@gmail.com>2020-04-16 21:37:16 +0200
committerAnton L. Šijanec <sijanecantonluka@gmail.com>2020-04-16 21:37:16 +0200
commitd8e4a5b71da218293214acc9c9b6be2ccb095271 (patch)
tree348d29f793c8774c2438d58d28b360452f624023 /f015_apihandler.ino
parentupdejtttttt (diff)
downloadsijaneciot-d8e4a5b71da218293214acc9c9b6be2ccb095271.tar
sijaneciot-d8e4a5b71da218293214acc9c9b6be2ccb095271.tar.gz
sijaneciot-d8e4a5b71da218293214acc9c9b6be2ccb095271.tar.bz2
sijaneciot-d8e4a5b71da218293214acc9c9b6be2ccb095271.tar.lz
sijaneciot-d8e4a5b71da218293214acc9c9b6be2ccb095271.tar.xz
sijaneciot-d8e4a5b71da218293214acc9c9b6be2ccb095271.tar.zst
sijaneciot-d8e4a5b71da218293214acc9c9b6be2ccb095271.zip
Diffstat (limited to 'f015_apihandler.ino')
-rw-r--r--f015_apihandler.ino24
1 files changed, 22 insertions, 2 deletions
diff --git a/f015_apihandler.ino b/f015_apihandler.ino
index eeb974d..add1088 100644
--- a/f015_apihandler.ino
+++ b/f015_apihandler.ino
@@ -27,6 +27,7 @@ void handleRename() {
server.send(500, "text/html", fihr(500, "premikanje ni uspelo!"));
}
}
+
void handleTms() { // timeset
if (!preveriprijavo()) return;
if (!server.hasArg("s") || server.arg("s") == NULL) {
@@ -123,13 +124,15 @@ void handleSetSTA() {
void handleGetID() {
if (!preveriprijavo()) return;
if (!server.hasArg("k") || server.arg("k") == NULL) {
- server.send(400, "text/html", fihr(400, "obvezni argument: k(aj s(ta MAC)/a(p MAC)/i(p)/c(hipId)/h(ostname)). prebere ID, za pisanje MACa glejte /api/sta in /api/ap"));
+ server.send(400, "text/html", fihr(400, "obvezni argument: k(aj s(ta MAC)/a(p MAC)/i(p)/c(hipId)/h(ostname/u(ra))). prebere ID, za pisanje MACa glejte /api/sta in /api/ap"));
return;
}
if(server.arg("k").startsWith("s")) {
server.send(200, "text/plain", String(WiFi.macAddress()));
} else if (server.arg("k").startsWith("a")) {
server.send(200, "text/plain", String(WiFi.softAPmacAddress()));
+ } else if (server.arg("k").startsWith("u")) {
+ server.send(200, "text/plain", String(now()));
} else if (server.arg("k").startsWith("i")) {
server.send(200, "text/plain", WiFi.localIP().toString());
} else if (server.arg("k").startsWith("c")) {
@@ -197,6 +200,12 @@ void handleNewPassword() {
}
writefile("/403/webgeslo.txt", String(server.arg("g")));
}
+
+void handleForcedTimeUpdate() {
+ setTime(timeSyncProvider());
+ server.send(200, "text/html", fihr(200, "ok"));
+}
+
void handleFileUpload() {
if (!preveriprijavo()) return;
HTTPUpload& upload = server.upload();
@@ -219,11 +228,22 @@ void handleFileUpload() {
}
}
}
+
+void handleFile() {
+ if (!preveriprijavo()) return;
+ if (!server.hasArg("i") || server.arg("i") == NULL || !server.hasArg("v")) {
+ server.send(400, "text/html", fihr(400, "obvezena argumenta: i(me), v(sebina)"));
+ return;
+ }
+ writefile(String(server.arg("i")), String(server.arg("v")));
+ server.send(200, "text/html", fihr(200, "ok"));
+}
+
bool handleFileRead(String path) { // send the right file to the client (if it exists)
if (!preveriprijavo()) return false;
// Serial.println("handleFileRead: " + path); // 2hc
if (path.endsWith("/")) path += "index.html"; // If a folder is requested, send the index file
- if(path.indexOf("/403/") >= 0) {
+ if(path.indexOf("/403/") >= 0 && DISALLOW_403) {
server.send(403, "text/html", fihr(403, "prepovedano"));
return true;
}