Web Server feature customization

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.

URLsI haven’t found the code that uses this yet, but it seems pretty straight forward what this is used for.

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_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, 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 don’t know Javascript, CSS and only a little bit of HTML, this part is going to be a challenge. I did finally get what I was trying to do.  Seems like a small step, but it took a lot of studying and tinkering.

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.

Web Page Hello World

Serial Hello World

First web page

I have the web server up and running which is great.

While reviewing my design, I found a few mistakes in the layout.  These mistakes are easily fixed with either a jumper wire or solder bridge, so I can keep on testing when the new PCBs arrive.

The web server isn’t working as easily as I had hoped.  I made a copy of the cats web page in the project, added my banner photo from this site and added html links in each page to point to the new page. With my picture added, It wouldn’t compile.  I am sure there is enough room in ROM, so I just need to figure out some settings. I removed the picture from the project and it compiles. I added an entry in my hosts file to point to smart.relay.com. When I go to smart.relay.com on my network it seems to work most of the time.  Speed and reliability will need to be worked on.

My new page unfortunately comes up blank. If I add .html to the end of the url my page loads correctly.  I went through the pages and added the .html ending to each link.  I don’t understand why this is happening this way.

I opened and modified the eagle.app.v6.ld  I changed the irom_0_seg  line. I changed the len value from 0x51000 to 0x80000.  This allowed me to add the banner photo into the project.  I don’t know if this can cause problems.  Assuming the value was at 0x51000 for a reason gives me reason to be concerned about it.  It’s possible that I have allowed data to overlap which could cause major problems. I need to learn how the .ld linker files work.