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 lifecycleexamples/awslambda.py: AWS Lambda handler integration with streaming supportexamples/capture.py: Request inspection with catch-all routes and body streamingexamples/client.py: HTTP client with connection pooling and keepaliveexamples/client-gzip.py: HTTP client with GZip decompressionexamples/client-sse.py: HTTP client consuming Server-Sent Events streamsexamples/cors.py: CORS headers, pre-flight handling, and cross-origin requestsexamples/fileserver.py: Static file serving with MIME type detectionexamples/htmx.py: Interactive web apps with HTMX and server-side renderingexamples/middleware.py: Pre/post middleware decorators for request/response processingexamples/proxy.py: Reverse proxy with header manipulation and forwardingexamples/sse.py: Server-Sent Events streaming with async generatorsexamples/upload.py: File upload handling with HTML formsexamples/watch.py: Filesystem change streaming via SSE using CLI watchersexamples/workers.py: Background task processing with asyncio queues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file extra_http-1.1.1.tar.gz.
File metadata
- Download URL: extra_http-1.1.1.tar.gz
- Upload date:
- Size: 76.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e309162537a9d935b963e1af6ce2e7dd90d5d40d2c627b96af6f20c5a9bd12f1
|
|
| MD5 |
d0dbd0851dec199df8bef4b959dfacf9
|
|
| BLAKE2b-256 |
4d97d723cb71b62af0bff45fcbd15df1b66e7a8974b1ee72774a1cbb35d0d5ae
|
File details
Details for the file extra_http-1.1.1-py3-none-any.whl.
File metadata
- Download URL: extra_http-1.1.1-py3-none-any.whl
- Upload date:
- Size: 85.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad6bb0011f07efe9d3abb91b5573c1171347d95c181a90b4386cdbb9ac1cc85f
|
|
| MD5 |
f137707c83f2c411f8dce67ac5306ff1
|
|
| BLAKE2b-256 |
506c252c05a0012fae9b6b51ebf651215dd755340dae5474c260c3c1aadcc996
|