api-reference HTTP SERVER help
Posted: Mon Sep 24, 2018 9:47 am
I was reading the api-reference for HTTP SERVER here:
https://docs.espressif.com/projects/esp ... erver.html
I tried the example in \esp-idf\examples\protocols\http_server\simple, and it works just fine.
Yet its all clear as mud to me.
I added a handler to catch a request to the main page, and this worked fine, but yet now i am stumped on the proper way to serve an actual html page. I know the .html to send, but how to place it inside the main_page_get_handler() properly and with the correct response type. I have always been a example type of learner. Reading a doc like that means very little to me. Without an actual example serving a web page, or showing it turning on/off say a led I get stumped quickly with just the api-referenece.
Anyone mind sharing some tid bits ?
I have added my own httpd_register_uri_handler(server, &mainPage);
https://docs.espressif.com/projects/esp ... erver.html
I tried the example in \esp-idf\examples\protocols\http_server\simple, and it works just fine.
Yet its all clear as mud to me.
I added a handler to catch a request to the main page, and this worked fine, but yet now i am stumped on the proper way to serve an actual html page. I know the .html to send, but how to place it inside the main_page_get_handler() properly and with the correct response type. I have always been a example type of learner. Reading a doc like that means very little to me. Without an actual example serving a web page, or showing it turning on/off say a led I get stumped quickly with just the api-referenece.
Anyone mind sharing some tid bits ?
I have added my own httpd_register_uri_handler(server, &mainPage);
Code: Select all
esp_err_t main_page_get_handler(httpd_req_t *req)
{
printf("Main Page Requested\r\n");
return ESP_OK;
}
httpd_uri_t mainPage = {
.uri = "/",
.method = HTTP_GET,
.handler = main_page_get_handler,
/* Let's pass response string in user
* context to demonstrate it's usage */
.user_ctx = NULL
};