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

Uploaded Source

Built Distribution

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

Uploaded Python 3

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