Modules | |
Functions | |
Definitions | |
Data Structures | |
The HTTP server displays web pages located in Flash Memory and/or RAM. To add HTTP-server support include httplib.h in your application and link http.lib to your project. The definition of web pages is similar to the FTP-server directory and file definition. To specify a page or GIF located in RAM, the content must be converted into a c-array and be included in main. Use program Makewebpage to recursively convert all html and image files within an entire subdirectory into a single file.
A simple
#include ".\webpage\webpage.c" // web page content
adds all web page contents to your project.
The generated file webpage.c contains two kinds of information for each web-element:
To make the generated web-elements accessible to the web-server, a list of all elements must be built and assigned to a user named "webserver". Example:
This user list must now be passed as argument to http_server_init() during initialization:
The interface between a HTTP request and the user reply is a user defined HTTP interpreter callback function. All HTTP requests cause a callback function call and the user is responsible to answer this request.
To make a webpage dynamic, either change the content of a file e.g. by overwriting a place holder in a html page, or by changing the file itself:
Instead of calling fsys_init_file() the file parameters can be changed immediately:
To reduce memory and to accelerate transmission gzip compressed files can be used. For this use a common file compression utility and gzip the desired file. The compressed file name must be identical to the original file name. Add the flag HTTP_GZIP to direntry_type::access to let the HTTP server generate the suitable compressed file header.
Example HTTPsimple.c uses compressed files. Website generation tool Makewebpage is called with parameter 'z' to set flag HTTP_GZIP for all files.