This project explores three different ways to serve web content using pure Python—no frameworks. Each server demonstrates a different backend architecture style:
- CGI Calculator – Traditional Common Gateway Interface server
- WSGI Book Catalog – Web Server Gateway Interface using TinyDB
- Socket HTTP Server – Raw socket implementation of an HTTP server
Ideal for learning fundamental web backend mechanics and Python networking.
.
├── cgi/ # CGI calculator
│ └── cgi-bin/
│ └── cgi_calc.py
├── wsgi/ # Book catalog using WSGI + TinyDB
│ ├── main.py
│ ├── initial_books.json
│ └── books_db.json
├── simple_server/ # HTTP server using sockets
│ ├── http_server.py
│ ├── tests.py
│ ├── unit-tests.py
│ └── webroot/
│ ├── a_web_page.html
│ └── images/
└── README.mdA web-based calculator implemented with CGI. Accepts operands and operations via query string:
http://127.0.0.1:8000/cgi-bin/cgi_calc.py?user=jdoe&operand=11&operand=7&operation=div
cd cgi
python -m http.server --cgiA WSGI server using TinyDB to manage a searchable book catalog. Users can:
- View all books
- Add new books
- Search by title, author, and year
http://localhost:8000/books/search?title=1984
http://localhost:8000/books/search?year=1925&title=The%20Great%20Gatsby
cd wsgi
python -m venv .venv && source .venv/bin/activate
pip install tinydb
python main.pyImplements an HTTP 1.1 server using Python sockets. Supports:
- Directory browsing
- MIME-type detection
- Static file serving (HTML, text, images, etc.)
cd simple_server
python -u http_server.pyThen visit:
The socket server includes basic tests using unittest:
python unit-tests.py
python tests.py📌 Note: You may need to add a delay in the test setup to ensure the server boots before tests run.
- Understand core differences between CGI, WSGI, and socket-level web servers.
- Learn request parsing, routing, and response generation at different abstraction levels.
- Gain experience with Python’s standard library:
http.server,wsgiref,socket, andTinyDB.
This project is licensed under the MIT License.
Uriah McKinney
Senior Technical Program Manager, Backend Developer-in-Training
GitHub • LinkedIn
- Add logging for request tracing
- Dockerize the WSGI app
- Optional: Execute
.pyscripts dynamically in the socket server