How to build a web framework using Python 3 stdlib (http.server / sockets)

Build Brooklet, a tiny teaching web framework with routing, templates, middleware, and packaging notes with Python 3 stdlib (http.server / sockets).

  • Difficulty Intermediate
  • Parts 12
  • Stack Python 3 stdlib (http.server / sockets)

What you are building

Brooklet is a web framework you assemble in twelve short stages. The teaching stack is Python (Python 3 stdlib (http.server / sockets)). By the end you should understand the shell, the data you persist, and the everyday workflows people expect from this kind of app.

Building a tiny framework teaches routing, request objects, and middleware better than only consuming Flask or Django.

There is no window—students curl endpoints and browse HTML the framework renders. Keep the public API small and documented.

Work in order. Early folders are intentionally small so you can see the window (or server) boot before features pile on. From the data-layer part onward, each snapshot should still run after you install dependencies.

How to use these lessons

Read the goal, clone the matching GitHub folder, run it, then skim the code against the notes below. If something fails, fix the run path first—most “bugs” on day one are the wrong directory or a skipped install.

Open the Brooklet GitHub repo →

Parts in order

Each chapter below is one checkpoint. Open a part when you are ready for that feature—not all at once.