load html file during compile time

This commit is contained in:
Peter Gu 2024-03-22 15:51:43 +01:00
parent 552e085282
commit 81fabcb537
2 changed files with 14 additions and 5 deletions

View File

@ -1,9 +1,11 @@
#include "esp_log.h" #include "esp_log.h"
#include <http/server.h> #include <http/server.h>
#include <nvs/nvs.h> #include <nvs/nvs.h>
#include <wifi/wifi.h> #include <wifi/wifi.h>
const http::response_t text_html = {
#include "res/test.html"
};
void start_ap() { void start_ap() {
nvs::init(); nvs::init();
@ -36,10 +38,12 @@ void start_http_server() {
// TODO // TODO
}}); }});
http::set_handlers({{http::Method::get, "/", http::set_handlers({{http::Method::get, "/",
[]() { []() {
return http::response_t{ return text_html;
"<html><body style=\"background:black; color: " //http::response_t("res/test.html")
"white\">Home</body></html>"}; //http::response_t{
// "<html><body style=\"background:black; color: "
// "white\">Home</body></html>"};
}}, }},
{http::Method::get, "/hello1", {http::Method::get, "/hello1",
[]() { []() {

5
res/test.html Normal file
View File

@ -0,0 +1,5 @@
"<html>"
"<body style=\"background:black; color: white\">"
"Home"
"</body>"
"</html>"