Dynamic HTTP Server
A few illustrated reminds about simple static http server.
For complete explanations, please have a look at : https://web.enib.fr/~harrouet
Getting server script results in a web browser client
REM : think about making the CGI file executable (chmod +x).
httpServer_dyn_1.c
Le fichier iot/linux-server-programming/dynamic-http-server/code_cgi/httpServer_dyn_1.c n'a pas été trouvé à l'emplacement spécifié.
# RPI Terminal
./exec_httpServer_dyn_1 5555
new HTTP connection from 192.168.0.1:40256
GET /script.cgi HTTP/1.1
Host: 192.168.0.2:5555
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1Application : Controlling RPI Led from the web browser
Configuring GPIO4 LED
Here we are in the RPI Terminal.
The following lines should be written in a bash script and recorded in /etc/profile.d to be executed on RPI startup.
$ echo 4 > /sys/class/gpio/export # create the GPIO4 folder
$ echo out > /sys/class/gpio/gpio4/direction # make direction out for ledOnce config done, try :
$ echo 1 > /sys/class/gpio/gpio4/value # switch the LED on
$ echo 0 > /sys/class/gpio/gpio4/value # switch the LED offControl GPIO4 with CGI script
The executed script is a bash one ; another example can be done with a lua script ( in www/cgi )
control_led.html - control_gpio4.sh
Le fichier iot/linux-server-programming/dynamic-http-server/code_led/www/control_led.html n'a pas été trouvé à l'emplacement spécifié.
Le fichier iot/linux-server-programming/dynamic-http-server/code_led/www/cgi/control_gpio4.sh n'a pas été trouvé à l'emplacement spécifié.
Control GPIO4 led with AJAX
Previously we were obliged to download the whole page.
The ajax-way permits to refresh only a part of this page after a client request.
control_led_ajax.html - ajax_gpio4.sh
Le fichier iot/linux-server-programming/dynamic-http-server/code_led/www/control_led_ajax.html n'a pas été trouvé à l'emplacement spécifié.
Le fichier iot/linux-server-programming/dynamic-http-server/code_led/www/cgi/ajax_gpio4.sh n'a pas été trouvé à l'emplacement spécifié.