Skip to main content

A toolkit to write HTTP/1.1 web services and applications, with first class support for streaming

Project description

                  __                   ._.
  ____  ___  ____/  |_ _______ _____   | |
_/ __ \ \  \/  /\   __\\_  __ \\__  \  | |
\  ___/  >    <  |  |   |  | \/ / __ \_ \|
 \___  >/__/\_ \ |__|   |__|   (____  / __
     \/       \/                    \/  \/

Extra is an toolkit to write HTTP/1.1 web services and applications, with first class support for streaming.

Extra works also well in serverless mode, thanks to its AWS Lambda handler.

Extra is focused on providing primitives for creating web services, implemented to work well both in development and production while providing a great developer experience.

Key Features:

  • Server and client, with full control over requests and responses
  • AWS Lambda/Serverless support
  • Streaming reads and writes, lazy decoding and encoding
  • Embedded asynchronous HTTP/1 development server
  • No dependency, only requires Python stdlib
  • Good baseline performance, competitive with FastAPI (5-10K RPS on average hardware)

Design principles:

  • Declarative: decorators to expose methods as web services
  • Stream-oriented: encourages writing stream processing handlers
  • Service focused: template are left out, but lots of building blocks are available for services.

Highlights:

  • Pre/post conditions for request handlers
  • HTML templating (plays nice with HTMX)
  • CORS support
  • Configurable proxy support
  • Integrated logging
  • Regexp-based tree router

Extra is the successor of Retro, one of the oldest decorator-based framework for HTTP applications and built on the 15+ years of experience developing and maintaining that toolkit.

Like Retro, Extra is designed as a kit, providing easily composable building blocks that help you build fast, readable and resilient web services.

Similar projects include Quart, Starlette, bareASGI and of course, FastAPI.

Example: Hello, World! Service

Here is helloworld.py:

#!/usr/bin/env uv run --with extra-http
from extra import Service, HTTPRequest, HTTPResponse, on, run

class HelloWorld(Service):
    @on(GET="{any}")
    def helloWorld(self, request: HTTPRequest, any:str) -> HTTPResponse:
        return request.respond(b"Hello, World !", "text/plain")

app = run(HelloWorld())

More examples

  • examples/api.py: JSON API with routing, type conversion, and service lifecycle
  • examples/awslambda.py: AWS Lambda handler integration with streaming support
  • examples/capture.py: Request inspection with catch-all routes and body streaming
  • examples/client.py: HTTP client with connection pooling and keepalive
  • examples/client-gzip.py: HTTP client with GZip decompression
  • examples/client-sse.py: HTTP client consuming Server-Sent Events streams
  • examples/cors.py: CORS headers, pre-flight handling, and cross-origin requests
  • examples/fileserver.py: Static file serving with MIME type detection
  • examples/htmx.py: Interactive web apps with HTMX and server-side rendering
  • examples/middleware.py: Pre/post middleware decorators for request/response processing
  • examples/proxy.py: Reverse proxy with header manipulation and forwarding
  • examples/sse.py: Server-Sent Events streaming with async generators
  • examples/upload.py: File upload handling with HTML forms
  • examples/workers.py: Background task processing with asyncio queues

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

extra_http-1.1.0.tar.gz (66.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

extra_http-1.1.0-py3-none-any.whl (74.8 kB view details)

Uploaded Python 3

File details

Details for the file extra_http-1.1.0.tar.gz.

File metadata

  • Download URL: extra_http-1.1.0.tar.gz
  • Upload date:
  • Size: 66.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for extra_http-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9dae5015307ea9eb4fbb31bd4dd6d4ca71289f4a6f5adabadc19739ab1f1e1c5
MD5 b48a1f38272d05ba69bc8cb34d572260
BLAKE2b-256 f082d68b18509d72ae2f519ba1f2342eb9c27c2be981242ccf9b9d8747d81ca3

See more details on using hashes here.

File details

Details for the file extra_http-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: extra_http-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 74.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for extra_http-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35136890f81f60d3b6afe64b9b5d40733cd339ea3eb472b8b6aaac18443d4c7c
MD5 b5be1cf1359a41b0e69ad0ba1044360e
BLAKE2b-256 1f89f209b8b45c7f7078b0f5652a2767b648e4ab795b1a95bf4596db8c068743

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page