12345678910111213141516171819202122232425262728293031323334353637 |
- void handleSaveMac() {
- if (server.hasArg("mac")) {
- // Extract the string from the POST request
- String data = server.arg("mac");
- // Open the file in write mode
- File file = LittleFS.open(DB_PATH, "w");
- if (!file) {
- server.send(500, "text/plain", "Failed to open file for writing");
- return;
- }
- // Write the string data to the file
- file.print(data);
- file.close();
- sendOK();
- } else {
- server.send(400, "text/plain", "No string provided in the request");
- }
- }
- void handleGetMac() {
- // Open the file in read mode
- File file = LittleFS.open(DB_PATH, "r");
- if (!file) {
- server.send(500, "text/plain", "Failed to open file for reading");
- return;
- }
- // Read the string data from the file
- String data = file.readString();
- file.close();
- // Send the string data as the json resp
- server.send(200, "application/json", data);
- }
|