I found out why my URLs without .html on the end weren’t being handled the same as the rest. There is an array defined in app.c that maps URL paths to alternate paths.
In the function init_http_server in app.c I found several functions that I think I don’t want. I put a // at the beginning of those lines so that the compiler treats those lines of code as comments. This is called “commenting out”. This is useful when removing code that you suspect has an error, or , as in this case, I suspect I can remove.
I don’t need the captive portal. I am happy if users can use the IP address to get to the web server. Having a domain name and using the web server from within a local network complicates things.
I commented out the lines:
http_server_bind_domain(INTERFACE_DOMAIN); http_server_enable_captive_portal(); and http_server_bind_urls((http_server_url *)&api_urls);
I compiled with these changes, “crossed my fingers”, and uploaded. And… I got a continuous stream of reboots with messages coming into the serial terminal program at 115,200. this means it started the code that initializes the UART and failed some time after that.
Backing up, I uncommented the server_bind lines and again tested on my board. I am able to connect to the Access Point with my android phone. When I point my phone browser to 192.168.4.1, I get an empty page. When I point my desktop browser to the assigned network address, I also get a blank page from the server. When I point either browser to smart.relay.com. they both load the initial webpage.
I decided to do a hello world cgi function trying to understand how things work. To the api_urls I added an entry pointing to a new function called http_tst_api_hello. I then added that function to the cgirelay.c and cgirelay.h files. The new function will send “Hello World” out on the serial port using the DBG macro. The new button shows up on the page, but doesn’t appear to do anything except cause a jump to the top of the page.
I am not putting any of this code up on github, because I am only taking steps to learn how things work. When I start building in real functionality, then I will start putting this code on github.