Introducing esp_httpd - A simple HTTP server for Arduino+ESP
Posted: Sun Nov 13, 2016 9:01 pm
esp_httpd is a simple, entirely event-driven HTTP server for serving files and responding to RESTful requests, intended for use in Arduino-based projects. An ESP8266's underlying networking framework presents an event-driven interface so it was decided that all interaction with the networking framework would use this interface.
To be useful in a variety of projects it was decided that esp_httpd should be able to:
The aspect of libesphttpd that really caught my attention was the routing array. I appreciate how the array codifies URI's to which the server is prepared to respond. Because esp_httpd is intended to be used in a RESTful manner it expands the routes specification to include the required method, if any.
esp_httpd is very much a work in progress - my first GitHub submitted projects. Your feedback is welcome and greatly appreciated.
https://github.com/gregschumacher/esp_httpd
To be useful in a variety of projects it was decided that esp_httpd should be able to:
- Serve files stored in flash using SPIFFS. These files will be static HTML, CSS, JS and images that comprise the host device's web interface.
- Differentiate between GET, POST, PUT, and DELETE requests. This is how the host device will correctly respond to AJAX requests.
- Parse key-value pairs in the URI or body. Data to be parsed can be submitted in the URI as a typical GET query string, or as key-value pairs in the body as in a typical POST. The data parsing should not be automatic in case raw or JSON-encoded data is sent in the body.
- Route to different handlers based on the URI furnished, with support for a trailing wildcard and cascading handlers.
- Use C-strings exclusively in place of Arduino String objects in an effort to minimize the potential for heap fragmentation.
The aspect of libesphttpd that really caught my attention was the routing array. I appreciate how the array codifies URI's to which the server is prepared to respond. Because esp_httpd is intended to be used in a RESTful manner it expands the routes specification to include the required method, if any.
esp_httpd is very much a work in progress - my first GitHub submitted projects. Your feedback is welcome and greatly appreciated.
https://github.com/gregschumacher/esp_httpd