Page 1 of 1

Does anyone have an example of a web server?

Posted: Mon Sep 04, 2017 6:20 pm
by jpan127
I am looking for an example of the ESP32 being able to display html/javascript on a web page for example: 192.168.1.250

I actually have no idea of this concept so any pointers to what concepts to look at would be appreciated. I think the ESP32 would need to be a web server and process HTTP requests.

I have looked at Kolban's C++ snippets on HTTP and they seem thorough but I have some trouble understanding what's going on. If you see this Kolban, I just sent you an email inquiring about possibly doing a video tutorial on this topic, it would be greatly appreciated.

For starters I would like to understand what is required to get this set up. So far, I think the ESP32 should listen on port 80 for HTTP requests, process them, and return html/javascript? However it does seem much more complicated than that.

Thanks!

Re: Does anyone have an example of a web server?

Posted: Thu Sep 07, 2017 6:54 am
by iot-bits.com
I ported HTTPD to ESP32 and the sockets work fine, but the code is very unstable right now. Plus I don't know what would be the best way to store files. SD card?

Re: Does anyone have an example of a web server?

Posted: Thu Sep 07, 2017 2:29 pm
by kolban
I am working on a sample that is an HTTP Server with WebSockets and file access ... as a library that is built and consumable from C++.

See .. https://github.com/nkolban/esp32-snippe ... Server.cpp

However ... as of September 7th 2017, it is not ready for consumption. It is what I am actively tinkering with ... should expect it to be ready for play in October.

Again, this is just another HTTP server ... and we are already awash in those. My goal in re-inventing the wheel here is to 100% leverage C++ and make it 100% C++ based (classes, callbacks, encapsulation etc etc).

Re: Does anyone have an example of a web server?

Posted: Fri Sep 08, 2017 9:58 am
by sukeshak
Is this something we can use directly? Not looked into yet.

http://www.freertos.org/FreeRTOS-Plus/F ... ver.html?0

Re: Does anyone have an example of a web server?

Posted: Fri Sep 15, 2017 1:37 pm
by cmorgan
I'm having good luck with libesphttpd. The esp-idf branch is what you want. You'll want to put that into the esp-idf/components/ folder like esp-idf/components/libesphttpd and then look at the README.md for how to pass it an array of urls and initialize it.

In the near future I'll be pushing out a version with ssl (https) support as well as Linux support in case you'd like to test/debug under Linux.

You can find it at https://github.com/Spritetm/libesphttpd, my fork is at https://github.com/chmorgan/libesphttpd

Re: Does anyone have an example of a web server?

Posted: Fri Sep 15, 2017 1:42 pm
by cmorgan
Oh, and libesphttpd also supports bundling and compressing files to a in-flash filesystem. This makes it super easy to include your resources in your project like images etc by simply putting them into a target folder and letting libesphttpd leverage heatshrink and gzip to compress and build them into a filesystem object that is built directly into your output application image.

If you run into any issues please let me know.

cmorgan wrote:I'm having good luck with libesphttpd. The esp-idf branch is what you want. You'll want to put that into the esp-idf/components/ folder like esp-idf/components/libesphttpd and then look at the README.md for how to pass it an array of urls and initialize it.

In the near future I'll be pushing out a version with ssl (https) support as well as Linux support in case you'd like to test/debug under Linux.

You can find it at https://github.com/Spritetm/libesphttpd, my fork is at https://github.com/chmorgan/libesphttpd

Re: Does anyone have an example of a web server?

Posted: Fri Sep 15, 2017 3:53 pm
by WiFive
cmorgan wrote:
In the near future I'll be pushing out a version with ssl (https) support
Sounds good. And wss:// too?

Re: Does anyone have an example of a web server?

Posted: Fri Sep 15, 2017 6:40 pm
by cmorgan
WiFive wrote:
cmorgan wrote:
In the near future I'll be pushing out a version with ssl (https) support
Sounds good. And wss:// too?
Yep, it uses the same transport portions of the server so wss:// comes for free when you enable SSL mode.

Re: Does anyone have an example of a web server?

Posted: Fri Sep 15, 2017 7:29 pm
by cmorgan
WiFive wrote:
cmorgan wrote:
In the near future I'll be pushing out a version with ssl (https) support
Sounds good. And wss:// too?
Alright, pushed the changes out to https://github.com/chmorgan/libesphttpd ... f_chmorgan if you'd like to give it a test spin. It's working well here.

Re: Does anyone have an example of a web server?

Posted: Sat Sep 16, 2017 4:57 pm
by cmorgan
I also pushed out an example of using libesphttpd under Linux at https://github.com/chmorgan/libesphttpd_linux_example