From 81fabcb53748aca924a3c3cb45a2fb6adb67d4b1 Mon Sep 17 00:00:00 2001 From: Peter Gu Date: Fri, 22 Mar 2024 15:51:43 +0100 Subject: [PATCH] load html file during compile time --- main/src/main.cpp | 14 +++++++++----- res/test.html | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 res/test.html diff --git a/main/src/main.cpp b/main/src/main.cpp index 2a8d501..552e57f 100644 --- a/main/src/main.cpp +++ b/main/src/main.cpp @@ -1,9 +1,11 @@ #include "esp_log.h" - #include #include #include +const http::response_t text_html = { + #include "res/test.html" +}; void start_ap() { nvs::init(); @@ -36,10 +38,12 @@ void start_http_server() { // TODO }}); http::set_handlers({{http::Method::get, "/", - []() { - return http::response_t{ - "Home"}; + []() { + return text_html; + //http::response_t("res/test.html") + //http::response_t{ + // "Home"}; }}, {http::Method::get, "/hello1", []() { diff --git a/res/test.html b/res/test.html new file mode 100644 index 0000000..fc7a5bf --- /dev/null +++ b/res/test.html @@ -0,0 +1,5 @@ +"" + "" + "Home" + "" +"" \ No newline at end of file