Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20691 Discussions

Modified web server that parses server-side text

Altera_Forum
Honored Contributor II
1,512 Views

This is a modified edition of the "web_server" example included with Nios II. It runs on MicroC/OS-II and the sockets-based LWIP stack. The attached files merely replace the provided http.c/http.h files found in the web_server example. The difference between original Altera-provided web server example and this are explicitly commented. 

 

The idea is that you get a "pseudo" server-side include that more full-featured web servers offer. The chief limitation is that the text being replaced must match length with the token that is searched for; this allows the server to operate in a more efficient manner as it sends out the HTTP "content length" based on the file length from the file system. It also allows the server to send 'chunks' of a file without first checking to see if a token is present in the file; if a token is detected in a 'chunk' that is to be sent, the text is replaced. If necessary more of the file is read if the token is not completely read at the end of the file 'chunk'. 

 

This code has the additional feature of parsing strings embedded statically into HTML content and replacing them with text... in this case, the system IP/MAC address, etc. A string of "%macaddr123456789" embedded in the HTML would be replaced with a MAC address, such as "00:11:22:33:44:55". The code does the same for IP addresses, but since IP addresses (printed in decimal) can vary in length the code "pads" the new HTML with space characters.  

 

You can easily modify this example to print out something other than network settings at runtime in your application. The only restriction is that the string length of what you're displaying must be constant. 

 

No warranty expresed or implied, not an official Altera product; no support is offered on this modified example.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
552 Views

hi, 

i downloaded ur code and i runned it,it is fine.but how to use this web server i m not getting,because it is giving the same o/p as the original web server.how to change the html file web contents dynamically. 

thank you 

manish
0 Kudos
Altera_Forum
Honored Contributor II
552 Views

hi, 

i have suceessfully builded ur code,but i dont know how to use it and how to show our output.can u please tell me the details of ur project and what results we obtain with this. 

please help me,i m in trouble. 

thanks in advance 

manish, 

vnitmanish@gmail.com
0 Kudos
Reply