Skip to content

kolos/esp8266-create-api-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

esp8266-create-api-table

This python prebuild script generates an html table in a cpp header file for the available HTTP endpoints configured with ESP8266WebServer.

Screenshot

Screenshot

Sample of the output file: http_apis.h

PROGMEM const char http_apis_html_content_type[] = "text/html";
PROGMEM const char http_apis_html[] = {0x1f, 0x8b, 0x8, 0x0, ....};
const uint16_t http_apis_html_len = 374;

How does it work

  1. Scans *.ino files for ESP8266WebServer instances
  2. Scans ESP8266WebServer instances for server.on(arg1, arg2, arg3) calls
  3. Scans arg3 for HTTP parameters
    1. in case of arg3 is not an inline function, scans for function in *.ino files
    2. else scan the inline function []() for content
  4. Creates an HTML table with the path, request method and argument list
  5. Compresses the table with gzip to save some space
  6. Saves the content to a cpp header file: http_apis.h

How to use

  1. Download the script file
  2. Reference as a prebuild script in .vscode/arduino.json:
    "prebuild": "python <your file directory>/make_urls.py"
  3. Add to your .ino file the HTTP serving snippet:
    server.on("/list_apis", HTTP_GET, []() {
        server.sendHeader("Content-Encoding","gzip");
        server.send_P(200, http_apis_html_content_type, http_apis_html, http_apis_html_len);
    });

Dependencies

  1. VS Code + Arduino plugin
  2. python3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages