This commit is contained in:
Matthew Frost 2024-04-13 17:16:27 +02:00
parent bafb0e8e9d
commit 7d166f3900
3 changed files with 22 additions and 5 deletions

View file

@ -40,6 +40,15 @@ class MainWebServerClass{
request->send(SPIFFS, "/index.html", String(), false, processor);
});
_server->on("/version", HTTP_GET, [&](AsyncWebServerRequest *request){
if(_authRequired){
if(!request->authenticate(_username.c_str(), _password.c_str())){
return request->requestAuthentication();
}
}
request->send(200, "application/json", "{\"version\":\"3.1.8\"}");
});
_server->onNotFound([&](AsyncWebServerRequest *request){
if(_authRequired){
if(!request->authenticate(_username.c_str(), _password.c_str())){

View file

@ -158,7 +158,6 @@ void setup() {
#endif
#ifdef TINANCE2_BACKEND
tinance2_http.setReuse(true);
#endif
#ifdef WEBHOOKS
@ -180,9 +179,15 @@ void setup() {
return;
}
#ifdef WEB_OTA_UPDATE
ElegantOTA.begin(&server, http_username, http_password);
#endif
#ifdef WEB_OTA_UPDATE
ElegantOTA.setAutoReboot(false);
ElegantOTA.onEnd([](bool success) {
if (success) {
ESP.restart();
}
});
ElegantOTA.begin(&server, http_username, http_password);
#endif
#endif

View file

@ -1,3 +1,6 @@
[env:mcu-esp32s-ota]
extra_scripts = platformio_upload.py
upload_protocol = custom
custom_upload_url = http://admin:admin@remotehost/update
custom_username = "admin"
custom_password = "b5JvsPZdTsb@MB66kVR2"
custom_upload_url = "http:/remotehost"