1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-09 06:42:20 +01:00

Make OTA function switchable in web_server component (#2685)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Laszlo Gazdag
2021-11-10 20:31:22 +01:00
committed by GitHub
parent 99c775d8cb
commit 0bdb48bcac
5 changed files with 23 additions and 5 deletions

View File

@@ -152,7 +152,9 @@ void WebServer::setup() {
#endif
this->base_->add_handler(&this->events_);
this->base_->add_handler(this);
this->base_->add_ota_handler();
if (this->allow_ota_)
this->base_->add_ota_handler();
this->set_interval(10000, [this]() { this->events_.send("", "ping", millis(), 30000); });
}
@@ -240,10 +242,14 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
#endif
stream->print(F("</tbody></table><p>See <a href=\"https://esphome.io/web-api/index.html\">ESPHome Web API</a> for "
"REST API documentation.</p>"
"<h2>OTA Update</h2><form method=\"POST\" action=\"/update\" enctype=\"multipart/form-data\"><input "
"type=\"file\" name=\"update\"><input type=\"submit\" value=\"Update\"></form>"
"<h2>Debug Log</h2><pre id=\"log\"></pre>"));
"REST API documentation.</p>"));
if (this->allow_ota_) {
stream->print(
F("<h2>OTA Update</h2><form method=\"POST\" action=\"/update\" enctype=\"multipart/form-data\"><input "
"type=\"file\" name=\"update\"><input type=\"submit\" value=\"Update\"></form>"));
}
stream->print(F("<h2>Debug Log</h2><pre id=\"log\"></pre>"));
#ifdef WEBSERVER_JS_INCLUDE
if (this->js_include_ != nullptr) {
stream->print(F("<script src=\"/0.js\"></script>"));