Skip to main content

A developer centric, performant Python web framework

Project description

xpresso

codecov Test & Release

Introduction

xpresso is an ASGI web framework built on top of Starlette, Pydantic and di, with heavy inspiration from FastAPI.

Some of the standout features are:

  • ASGI support for high performance (within the context of Python web frameworks)
  • OpenAPI documentation generation
  • Automatic parsing and validation of request bodies and parameters, with hooks for custom extractors
  • Full support for OpenAPI parameter serialization
  • Highly typed and tested codebase with great IDE support
  • A powerful dependency injection system, backed by di

Requirements

Python 3.7+

Installation

pip install xpresso

You'll also want to install an ASGI server, such as Uvicorn.

pip install uvicorn

Example

Create a file named example.py:

from typing import List, Optional
from pydantic import BaseModel
from xpresso import App, PathItem, FromPath, FromQuery

class UserModel(BaseModel):
    user_id: str
    age: Optional[int] = None

async def get_users(
    ids: FromPath[List[int]],
    include_age: FromQuery[bool],
) -> List[UserModel]:
    if include_age:
        return [UserModel(user_id=user_id, age=123) for user_id in ids]
    return [UserModel(user_id=user_id) for user_id in ids]

app = App(
    routes=[
        PathItem(
            path="/users/{ids}",
            get=get_users
        )
    ]
)

Run the application:

uvicorn example:app

For more examples, tutorials and reference materials, see our documentation.

See this release on GitHub: v0.1.1

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

xpresso-0.1.1.tar.gz (37.8 kB view details)

Uploaded Source

Built Distribution

xpresso-0.1.1-py3-none-any.whl (65.1 kB view details)

Uploaded Python 3

File details

Details for the file xpresso-0.1.1.tar.gz.

File metadata

  • Download URL: xpresso-0.1.1.tar.gz
  • Upload date:
  • Size: 37.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Linux/5.11.0-1025-azure

File hashes

Hashes for xpresso-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6782dc486278c5d847b18cae6808d0bba48904b1f117843f9ae3ae9916ae7e2a
MD5 fefd5cecbdbb0b097ab99c6b6658a142
BLAKE2b-256 41313d0e8ca0d22edcddce6204021f5545b61afc956bea7eb4f95424d3493f54

See more details on using hashes here.

File details

Details for the file xpresso-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xpresso-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 65.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Linux/5.11.0-1025-azure

File hashes

Hashes for xpresso-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a06a3ed5879c60618e25a3c50679d7a1bb3734c0a27529dcf6a0bedce574b874
MD5 3060d7458f5f10dff558ca8dedc6066c
BLAKE2b-256 2bfcd406d44a6fb5486116852efd8608aa414434ea3a4a8790f6434caf080612

See more details on using hashes here.

Supported by

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