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.

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.0.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

xpresso-0.1.0-py3-none-any.whl (65.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xpresso-0.1.0.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.9 Darwin/21.2.0

File hashes

Hashes for xpresso-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d2b59694da6657007310e652501ba1d641ee8cd298b6e433bc9198578cc4e18a
MD5 23fc25ad1b34ac6b10bb270859975e2e
BLAKE2b-256 185bec4011ce03c6050d34773cd91dcb6c813ad8c76c4378594e4dac76f98ef0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpresso-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.9 Darwin/21.2.0

File hashes

Hashes for xpresso-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1285aa2cdb394accb765568f2862484ea117f20a3e3e6b11392aa6abf88e22a
MD5 81c89f384b00b751bc2db42817ca6de8
BLAKE2b-256 cfc0df3ab2df0c1116fe2f178b86ffa729e21aad7f75755d19c2826d0aa8b9c6

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