json loading works now---> now to css

This commit is contained in:
richonguzman 2023-08-31 08:17:31 -04:00
parent 72fcf9d732
commit 6c1a8d155f
2 changed files with 33 additions and 0 deletions

24
data/iindex4.html Normal file
View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>Read JSON Lines</title>
</head>
<body>
<h1>Read JSON Lines</h1>
<ul id="jsonLines"></ul>
<script>
fetch('/igate_conf.json')
.then(response => response.json())
.then(data => {
const jsonLines = document.getElementById('jsonLines');
data.forEach(line => {
const listItem = document.createElement('li');
listItem.textContent = line;
jsonLines.appendChild(listItem);
});
})
.catch(error => console.error('Error reading JSON:', error));
</script>
</body>
</html>

View File

@ -280,15 +280,24 @@ void startServer() {
request->send(SPIFFS, "/index3.html", "text/html");
});
server.on("/test4", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(SPIFFS, "/index4.html", "text/html");
});
server.on("/testx", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(SPIFFS, "/testx.html", "text/html");//"application/json");
});
//setDefaultFile("testx.html");
if (Config.ota.username != "" && Config.ota.password != "") {
AsyncElegantOTA.begin(&server, Config.ota.username.c_str(), Config.ota.password.c_str());
} else {
AsyncElegantOTA.begin(&server);
}
server.serveStatic("/", SPIFFS, "/");
server.begin();
Serial.println("init : OTA Server ... done!");
}