Difference between revisions of "HTTPD"
(transfered Page from old wiki) |
m (Transfer image from old wiki) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | == | + | {{i18n|HTTPD}} |
− | + | {{Module | |
+ | |NAME=HTTPD | ||
+ | |MENUCONFIG={{Applications}}->HTTP Server->HTTPD | ||
+ | |STATUS={{stable}} | ||
+ | |PINNING=- | ||
+ | |ECMD=- | ||
+ | |CONTROL6=- | ||
+ | |DEPENDS=? | ||
+ | |REQUIRES=? | ||
+ | |CODE=? | ||
+ | }} | ||
− | |||
− | |||
− | |||
− | + | == Web server on the ethersex == | |
+ | The built-in web server in [[Ethersex]] can read the files it should serve from various locations: | ||
− | + | * from an external dataflash | |
+ | * files stored in the flash memory of the MCU right after the firmware | ||
+ | * run ECMD commands and serve the results (for AJAX) | ||
+ | Any of these sources for data can be enabled independent of the others. The easiest option is to initially keep the files in the internal flash memory and to access dynamic content via the HTTP ECMD interface. | ||
+ | |||
+ | === Configuration === | ||
<pre> | <pre> | ||
General Setup ---> | General Setup ---> | ||
Line 18: | Line 31: | ||
| | [ ] EEPROM (24cxx) Raw Access | | | | [ ] EEPROM (24cxx) Raw Access | | ||
| | [-] DC3840 Camera | | | | [-] DC3840 Camera | | ||
− | + | ... | |
Applications ---> | Applications ---> | ||
| | [*] HTTP Server | | | | [*] HTTP Server | | ||
| | [ ] Basic Authentication | | | | [ ] Basic Authentication | | ||
− | + | ... | |
Applications ---> | Applications ---> | ||
Etherrape Control Interface (ECMD) ---> | Etherrape Control Interface (ECMD) ---> | ||
Line 28: | Line 41: | ||
</pre> | </pre> | ||
− | === | + | === Embedding files === |
− | + | If the option ''Supply Inline Files'' is enabled, all files stored in | |
+ | ''vfs/embed/'' will be automatically packed with gzip and appended to the end | ||
+ | of the firmware when building the image. | ||
+ | Filenames remain unchanged, however the maximum length of filenames is 6 | ||
+ | characters. | ||
− | === | + | === Preprocess files with the C preprocessor or m4 === |
− | + | To include files dependent on configuration options (or not) respectively | |
+ | including only parts, if a certain option is enabled, they can be preprocessed | ||
+ | by cpp or m4, before the output is packed and appended to the firmware. | ||
+ | For that, the file must end in .cpp or .m4. When using cpp, all defines from | ||
+ | config.h/autoconf.h are accessible (e.g. ~np~ONEWIRE_SUPPORT~/np~). | ||
+ | When using m4, ~np~ONEWIRE_SUPPORT turns into conf_ONEWIRE ~/np~. | ||
− | === Content | + | === Content type of the files === |
− | + | Because the web server can not dynamically determine the content type, this | |
− | * S ( | + | information needs to be supplied in advance. |
− | * X ( | + | The content type is determined by the first character of the file name: |
− | * | + | * S (e.g. Sty.c): text/css |
+ | * X (e.g. Xow.ht): application/xhtml+xml; | ||
+ | * everything else is served as text/html | ||
− | === | + | === Access files from the SD card === |
− | + | To serve files from an SD card, they are copied to the SD card. | |
− | + | These can then be accessed by the browser via the following URL (IP and file | |
− | + | name must of course be changed) <pre>http://192.168.23.244/Filename</pre> | |
− | + | If the file is located in a folder on the SD card, it can be accessed via the | |
+ | following URL. <pre>http://192.168.23.244/Foldername/Filename</pre> | ||
+ | The length of filenames is not limited to 6 characters with the SD card. | ||
− | === | + | === Manually triggering ECMD commands (via HTTP) === |
− | + | To query the IP via ECMD, the following URL (the IP must of course be changed) | |
+ | can be accessed with the browser, returning the output via HTTP. | ||
<pre>http://192.168.23.244/ecmd?ip</pre> | <pre>http://192.168.23.244/ecmd?ip</pre> | ||
− | + | In order to use commands containing spaces, e.g. "1w list", the spaces must be | |
+ | replaced with "+" or "%20". The following command lists 1-wire sensors, if | ||
+ | any are present: | ||
<pre>http://192.168.23.244/ecmd?1w+list</pre> | <pre>http://192.168.23.244/ecmd?1w+list</pre> | ||
− | + | or | |
<pre>http://192.168.23.244/ecmd?1w%20list</pre> | <pre>http://192.168.23.244/ecmd?1w%20list</pre> | ||
− | === | + | === Ethersex start page === |
− | + | If the web server is compiled in, when accessing | |
+ | <nowiki>http://YOUR_ETHERSEX_IP/</nowiki> the browser should show such a page: | ||
− | [[ | + | [[File:Ethersex-screen-startseite.png|600px]] |
=== Dataflash === | === Dataflash === |
Latest revision as of 22:25, 13 August 2014
HTTPD | |
---|---|
Status | Stable
|
menuconfig | Applications->HTTP Server->HTTPD |
Pinning | - |
Ecmd | - |
Control6 | - |
Depends on | ? |
Requires | ? |
Code | ? |
Contents
Web server on the ethersex
The built-in web server in Ethersex can read the files it should serve from various locations:
- from an external dataflash
- files stored in the flash memory of the MCU right after the firmware
- run ECMD commands and serve the results (for AJAX)
Any of these sources for data can be enabled independent of the others. The easiest option is to initially keep the files in the internal flash memory and to access dynamic content via the HTTP ECMD interface.
Configuration
General Setup ---> [*] VFS (Virtual File System) support ---> | | [ ] Atmel SPI Dataflash | | | [*] VFS File Inlining | | | [ ] SD/MMC-Card Access | | | [ ] EEPROM (24cxx) Raw Access | | | [-] DC3840 Camera | ... Applications ---> | | [*] HTTP Server | | | [ ] Basic Authentication | ... Applications ---> Etherrape Control Interface (ECMD) ---> | | [*] ECMD support |
Embedding files
If the option Supply Inline Files is enabled, all files stored in vfs/embed/ will be automatically packed with gzip and appended to the end of the firmware when building the image. Filenames remain unchanged, however the maximum length of filenames is 6 characters.
Preprocess files with the C preprocessor or m4
To include files dependent on configuration options (or not) respectively including only parts, if a certain option is enabled, they can be preprocessed by cpp or m4, before the output is packed and appended to the firmware. For that, the file must end in .cpp or .m4. When using cpp, all defines from config.h/autoconf.h are accessible (e.g. ~np~ONEWIRE_SUPPORT~/np~). When using m4, ~np~ONEWIRE_SUPPORT turns into conf_ONEWIRE ~/np~.
Content type of the files
Because the web server can not dynamically determine the content type, this information needs to be supplied in advance. The content type is determined by the first character of the file name:
- S (e.g. Sty.c): text/css
- X (e.g. Xow.ht): application/xhtml+xml;
- everything else is served as text/html
Access files from the SD card
To serve files from an SD card, they are copied to the SD card. These can then be accessed by the browser via the following URL (IP and file
name must of course be changed)http://192.168.23.244/Filename
If the file is located in a folder on the SD card, it can be accessed via the
following URL.http://192.168.23.244/Foldername/Filename
The length of filenames is not limited to 6 characters with the SD card.
Manually triggering ECMD commands (via HTTP)
To query the IP via ECMD, the following URL (the IP must of course be changed) can be accessed with the browser, returning the output via HTTP.
http://192.168.23.244/ecmd?ip
In order to use commands containing spaces, e.g. "1w list", the spaces must be replaced with "+" or "%20". The following command lists 1-wire sensors, if any are present:
http://192.168.23.244/ecmd?1w+list
or
http://192.168.23.244/ecmd?1w%20list
Ethersex start page
If the web server is compiled in, when accessing http://YOUR_ETHERSEX_IP/ the browser should show such a page:
Dataflash
TODO