Skip to content

sebastien/extra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5d3edb4 · Mar 3, 2025
Sep 5, 2024
Jul 15, 2024
May 28, 2020
Jun 8, 2024
Oct 1, 2024
Jul 10, 2024
Nov 16, 2024
Sep 20, 2024
Sep 23, 2023
Mar 3, 2025
Mar 19, 2021
Jul 10, 2024
Feb 15, 2024
May 7, 2020
Apr 16, 2024
Sep 5, 2024
Aug 20, 2024
Sep 20, 2023
Oct 8, 2022

Repository files navigation

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

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

It 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:

  • Client and server
  • Streaming reads and writes, lazy decoding and encoding
  • Embedded asynchronous HTTP/1 development server
  • Only requires Python stdlib
  • Good baseline performance (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
  • 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 maintainig 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:

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())