mirror of
https://github.com/scottchiefbaker/ESP-WebOTA.git
synced 2024-08-30 18:12:33 +00:00
Merge pull request #13 from jamesfowkes/master
Add ability to set custom HTML
This commit is contained in:
commit
c98c830c24
@ -78,8 +78,9 @@ long WebOTA::max_sketch_size() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// R Macro string literal https://en.cppreference.com/w/cpp/language/string_literal
|
// R Macro string literal https://en.cppreference.com/w/cpp/language/string_literal
|
||||||
const char ota_html[] PROGMEM = "<h1>WebOTA Version: " WEBOTA_VERSION "</h1>"
|
const char ota_version_html[] PROGMEM = "<h1>WebOTA Version: " WEBOTA_VERSION "</h1>";
|
||||||
R"!^!(
|
|
||||||
|
const char ota_upload_form[] PROGMEM = R"!^!(
|
||||||
|
|
||||||
<form method="POST" action="#" enctype="multipart/form-data" id="upload_form">
|
<form method="POST" action="#" enctype="multipart/form-data" id="upload_form">
|
||||||
<input type="file" name="update" id="file">
|
<input type="file" name="update" id="file">
|
||||||
@ -150,7 +151,15 @@ int WebOTA::add_http_routes(WebServer *server, const char *path) {
|
|||||||
|
|
||||||
// Upload firmware page
|
// Upload firmware page
|
||||||
server->on(path, HTTP_GET, [server,this]() {
|
server->on(path, HTTP_GET, [server,this]() {
|
||||||
server->send_P(200, "text/html", ota_html);
|
String html = "";
|
||||||
|
if (this->custom_html != NULL) {
|
||||||
|
html += this->custom_html;
|
||||||
|
} else {
|
||||||
|
html += ota_version_html;
|
||||||
|
}
|
||||||
|
|
||||||
|
html += ota_upload_form;
|
||||||
|
server->send_P(200, "text/html", html.c_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handling uploading firmware file
|
// Handling uploading firmware file
|
||||||
@ -211,6 +220,9 @@ void WebOTA::delay(unsigned int ms) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebOTA::set_custom_html(char const * const html) {
|
||||||
|
this->custom_html = html;
|
||||||
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -26,9 +26,12 @@ class WebOTA {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int handle();
|
int handle();
|
||||||
|
|
||||||
|
void set_custom_html(char const * const html);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init_has_run;
|
bool init_has_run;
|
||||||
|
char const * custom_html = NULL;
|
||||||
String get_ota_html();
|
String get_ota_html();
|
||||||
long max_sketch_size();
|
long max_sketch_size();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user