Home Contacts Terms Send money


www.acmesystems.it


Write a simple HTTP server in Python

The default Python distribution has a built-in support to the HTTP protocol that you can use to make a simple stand-alone Web server.

Visit also:

The Python module that provides this support is called BaseFTTPServer and can be used in our programs just including it in our sources:

from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer

Hello world !

Let's start with the first basic example. It just return "Hello World !" on the web browser.

example1.py

Run it by typing:

debarm:~/playground/python/httpserver# python example1.py

Then open your web browser on this URL: http://fox_ip_address:8080.

"Hello World !" will appear on your browser and two log messages on the FOX console:

Started httpserver on port  8080
10.55.98.7 - - [30/Jan/2012 15:40:52] "GET / HTTP/1.1" 200 -
10.55.98.7 - - [30/Jan/2012 15:40:52] "GET /favicon.ico HTTP/1.1" 200 -

Serve static files

Let's try an example that shows how to serve static files like index.html, style.css, javascript code and images:

example2.py

This new example:

Run it by typing:

debarm:~/playground/python/httpserver# python example2.py

then open your web browser on this URL: http://fox_ip_address:8080.

An HTML home page will appear on your browser.

Read data from a form

Now explore how to read incoming data from an HTML form.

example3.py

Run this example:

debarm:~/playground/python/httpserver# python example3.py

and type your name in the "Your name" label.

Related links


ARIETTA-G25 : ARM9 Linux Embedded Module (128MB) EURO 20.00

Arietta G25 is a small and low-cost multi-chip module that integrates:

  • a ARM9 @ 400Mhz CPU Atmel AT91SAM9G25
  • a 128MB of DDR2 RAM
  • up to 3 USB 2.0 host ports
  • 20x2 pads for strip pitch 2.54mm (100mil)

Basic Version with no strips mounted


| Product description... |

COMBO-B43 : Acqua A5 + 4.3 inch TFT LCD evaluation kit EURO 149.00

Basic kit to evaluate the Acqua A25 SoM with TFT LCD 4.3 inch

Parts included:

  • ACQUA-256E-N256 SoM (256 MB RAM , 256 MB Nandflash)
  • 4.3 inch TFT LCD with resistive touch (Code LCD-43-RT)
  • Berta board A5 LCD (Code BERTA-A5-LCD)
  • WIFI-2 WiFi module with PCB antenna
  • 4GB bootable microSD with Debian Linux preinstalled (Code DEBM4G-ACQUA)
  • Debug port interface (Code DPI) with USB data cable
  • Wall adapter 5 volt @ 1A switching power supply (Code PS-5V1A-EU-MUSB)

| Product description | Acqua A5 catalog |




Acme Systems srl
Via Aldo Moro 53 - 00055 Ladispoli (RM) - Italy
P.IVA/C.F. 08114831004
Tel +39.06.99.12.187 - Fax +39.06.622.765.31
http://www.acmesystems.it
Iscritta al Registro delle Imprese di Roma al n. 08114831004


Atmel© Certified Partner

Documentation Terms of Use
Acme Systems provides this documentation "as is" without warranty or guarantees of any kind. We not provide any direct support for the Open Source preinstalled software but, through these pages and forum posts, all of the information required to obtain the sources, install, use and update the Open Source software that can be run on the Acme boards. Please note that all of the preinstalled software, used on the Acme Systems products, are Open Source so you have to check the license terms provided by the authors (usually the GPL) before using it in any commercial or non-commercial product, by yourself. Before to contact us please note that WE ARE MAINLY HARDWARE DESIGNERS and NOT LINUX GURUS and therefore could be better to post your questions to the Acme Systems forum and ensure that all of the site contributors and large software community can read and reply to your questions.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Creative Commons License