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


ARIAG25-128 : ARM9 Linux Embedded Module EURO 24.00

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

  • an ARM9 @ 400Mhz CPU Atmel AT91SAM9G25
  • a 128MB of DDR2 RAM
  • 10/100 Ethernet interface
  • up to 3 USB 2.0 host ports
  • Normal temperature range version (-0 +70)

| More info... |

TERRA : Linux embedded board for fast prototyping EURO 169.00

TERRA is a carrier board conceived both to evaluate the Aria G25 SoM and to make prototypes or small production batches of OEM equipments using the Daisy cabling system.

| Product description | Terra catalog |


FOXG20 : FOX Board G20 EURO 139.00

FOX Board G20 is a "ready-to-run" Embedded Linux System perfect to use as a solid state WEB server or as a core engine for your embedded appliances.

A fully Open Source environment is available to customize and build your own kernel image or to develop user applications using standard GNU tools. Version with Atmel AT91SAM9G20 with 256KB of FLASH memory, 64MB of RAM and up to 16GB of microSD.

FOXG20 needs some extra accessories in order to be operative:

  • a bootable microSD with Linux OS (see DEBM2G or DEBM4G products)
  • a 5 Volt DC power source (see PS5V1A product)
  • a 3V lithium battery for internal RTC circuitry (see CH23-1220 product)

An evalution kit with all the accessories you need to get started with FOX Board G20 is available on-line on this link: COMBO-2.


| More info... |




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