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.

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.


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 - - [30/Jan/2012 15:40:52] "GET / HTTP/1.1" 200 - - - [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:


This new example:

  • check the extension of the file requested file
  • set the right mime type to give back to the browser
  • open the static file requested
  • send it back to the browser

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.


Run this example:

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

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

Related links

Sergio Tanzilli
System designer, software developer and company co-founder
Webpages: https://www.acmesystems.it and http://www.tanzolab.it
Github repository: https://github.com/tanzilli and https://github.com/acmesystems

EUR 149.00

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

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
  • A bootable microSD with Debian Linux preinstalled
  • 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 |


Home Automation board for Raspberry Compute Module 3

More info