← Back to projects

Software & Open Source

HTTP-PyServer

A standard-library Python HTTP framework, published on PyPI, that exposes routing, request handling, sessions, caching, and templating through a compact API.

HTTP-PyServer project logo
DistributionPublished on PyPI
RuntimeNo third-party dependencies
CompatibilityPython 3.7+
LicenseMIT

Overview

HTTP-PyServer is a lightweight framework for creating HTTP servers in Python with a small, approachable API. It builds on Python's standard library rather than a third-party web framework, providing the core pieces needed to route requests, return files and structured data, manage sessions, cache information, and render templates.

I designed the server architecture, separated its behavior into reusable modules, packaged the project for installation with pip, and published it on PyPI. The project gave me practical experience with HTTP, sockets, concurrent request handling, API design, packaging, and maintaining a public software release.

A compact server API

The framework uses decorators to connect Python functions to routes while keeping the underlying server setup out of the application code. A basic server can be expressed in only a few lines:

import server

app = server.Server()

@app.route('/')
def home(request):
    return 'Hello, world!'

with app:
    app.wait('Press Enter to continue...')

This interface keeps simple applications concise while still exposing request data, response behavior, logging, templates, sessions, caching, and wildcard routes when a project needs more control.

How it is structured

  1. ListenThe server accepts incoming connections using Python's socket APIs.
  2. ParseRequest objects expose headers, query values, client information, and the HTTP method.
  3. RouteRegistered paths and wildcard patterns map requests to application functions.
  4. RespondResponse handling supports text, HTML, CSS, JavaScript, JSON, images, and video.
  5. Maintain stateSession and cache modules support user-specific and time-limited server data.

Engineering approach

I built the framework directly on Python's socket, threading, and ssl modules to understand the protocol and concurrency concerns normally hidden by a web framework. Responsibilities are separated across request parsing, response construction, route matching, rendering, sessions, caching, and server lifecycle modules rather than concentrated in one monolithic class.

The public API prioritizes short, readable application code while retaining explicit control over routes and exposed files. Thread-per-connection handling supports concurrent requests, and the runtime depends only on Python's standard library. This is a learning-oriented framework rather than a replacement for a hardened production server. Production use would require systematic coverage of malformed requests, parser edge cases, concurrent access, path traversal, TLS configuration, and sustained load.

Distribution

HTTP-PyServer is packaged with a pyproject.toml build configuration and distributed publicly through PyPI. Publishing it turned installation, release versioning, API documentation, licensing, and compatibility into product concerns alongside implementation.

PyPI monthly downloads