HTTP Server From Scratch

I always wondered how HTTP and servers worked under the hood. So I decided to build an HTTP web server from scratch, without relying on existing frameworks!
Software Engineering
Author

Vikrant Mehta

Published

October 25, 2024

Project Overview

I was always confused about what a “protocol” is and how HTTP actually works. In our application development courses, we used Flask to make web apps, and starting a server was super easy—just a couple of commands. Same with sessions- it was very easy to do, but I never understood it. This confused me to no end: what the hell was really happening behind those commands!? So I decided to build an HTTP server from scratch to satisfy this curiosity.

This project is a simple HTTP server built using Python from the ground up without relying on existing frameworks, except the low-level networking libraries. It’s built to explore what servers do, how HTTP works, and how do sessions work.

Features

  • An extensible router that lets you add routes and route-handlers
  • Sessions and Token management
  • Multithreading for handling concurrent requests
  • Request parser and response formatter
  • Logging for debugging and maintenance perspective
  • An OOP based design for the server

Tech Stack

  • Language: Python

  • Modules: socket (for low-level networking), and other built-in libraries like hashlib, logging, and threading

How to Run This Project Locally?

To run this server locally:

  1. Clone the Repository

    git clone https://github.com/vikrantmehta123/http-server
    cd http-server
  2. Run the Server
    Execute the main server script:

    python app.py

GitHub Repository
For more details, the full source code can be found on GitHub: Source Code