OVMS3-idf/examples/protocols/http_server/simple
Angus Gratton da4cb76f5a test: Refactor TFW load_source() method to only take the file path
Fixes issues where example tests for persistent_sockets and advanced_tests both
loaded a module named "client", causing a race condition.
2019-11-28 19:25:52 +08:00
..
main examples: protocol examples which use common connection component 2019-11-13 12:36:25 +01:00
scripts http_server examples : Updated tests and examples to demonstrate usage of httpd_register_err_handler() and accommodate for changes in default error handler behavior 2019-02-25 09:13:39 +00:00
CMakeLists.txt protocol examples: enable protocol examples for esp32sbeta 2019-11-01 11:14:10 +08:00
http_server_simple_test.py test: Refactor TFW load_source() method to only take the file path 2019-11-28 19:25:52 +08:00
Makefile examples/protocols/http(s)_server: use common network component 2019-04-15 03:32:05 +00:00
README.md build system: Use CMake-based build system as default when describing commands 2019-07-08 17:31:27 +10:00

Simple HTTPD Server Example

The Example consists of HTTPD server demo with demostration of URI handling : 1. URI \hello for GET command returns "Hello World!" message 2. URI \echo for POST command echoes back the POSTed message

  • Open the project configuration menu (idf.py menuconfig) to configure Wi-Fi or Ethernet. See "Establishing Wi-Fi or Ethernet Connection" section in examples/protocols/README.md for more details.

  • In order to test the HTTPD server persistent sockets demo :

    1. compile and burn the firmware idf.py -p PORT flash
    2. run idf.py -p PORT monitor and note down the IP assigned to your ESP module. The default port is 80
    3. test the example :
      • run the test script : "python2 scripts/client.py <IP> <port> <MSG>"
        • the provided test script first does a GET \hello and displays the response
        • the script does a POST to \echo with the user input <MSG> and displays the response
      • or use curl (asssuming IP is 192.168.43.130):
        1. "curl 192.168.43.130:80/hello" - tests the GET "\hello" handler
        2. "curl -X POST --data-binary @anyfile 192.168.43.130:80/echo > tmpfile"
          • "anyfile" is the file being sent as request body and "tmpfile" is where the body of the response is saved
          • since the server echoes back the request body, the two files should be same, as can be confirmed using : "cmp anyfile tmpfile"
        3. "curl -X PUT -d "0" 192.168.43.130:80/ctrl" - disable /hello and /echo handlers
        4. "curl -X PUT -d "1" 192.168.43.130:80/ctrl" - enable /hello and /echo handlers

See the README.md file in the upper level 'examples' directory for more information about examples.