Skip to main content

Minimalistic web framework

Project description

Rapis - Minimalistic web framework based on RSGI

Python versions Current version Current status PyPI - Downloads

this framework was inspired by FastAPI so syntax may be identical

⚠️ WARNING: Framework in early development, it is NOT READY for production

Key features:

  • Easy to use: Syntax was inspired by your favourite framework
  • Fast: Built on native RSGI protocol with MsgSpec support
  • Async Only: Supports only work with async requests handling
  • Validation: Built-in support of MsgSpec providing first-class Validation Speed
  • Functional that actually MATTER: Framework contains Only what you need to build API without unnecessary dependencies

Requirements

  • msgspec: A fast serialization and validation library

Installation

pip install rapis
# install any rsgi compatible web-server
pip install granian
# or simply
pip install rapis[standard] # includes granian in requirements

Example

# main.py
from rapis import AppRouter, Query, WebApp

router = AppRouter()


@router.get("/")
async def root() -> dict:
    return {}


@router.get("/echo")
async def parametrized_handler(
    data: Query[str] = "default",
) -> str:  # for now waiting for /echo?data=str if not given adds "default"
    return data


app = WebApp()
app.include_router(router)

Run

granian main:app

Better Example

# routes.py
from msgspec import Struct
from rapis import AppRouter, Query

router = AppRouter()


class Item(Struct):
    name: str


@router.get("/queries_with_struct")
async def fetch_item(item: Query[Item]):  # no default means required and will expect to receive all fields in query params
    return Item(name="query")  # automatically parses to {"name": "query"}


@router.post("/echo") # also put, patch
async def fetch_item(item: Item):  # will try to read and validate all fields from body
    return item
# main.py
from rapis import WebApp

from routes import router

app = WebApp()
app.include_router(router)

more examples

Performance

see benchmarks

Docs

see wiki

TODO

  • Exception handling
  • Built-in exception handlers (validation, json parsing)
  • Benchmarks section
  • Request/Response Work model
  • Docs
  • More availabilities to expand logic (custom routes and other)
  • better Query params handle
  • change routing from linear to something else (hash maps for static paths, ?? for dynamic paths)
  • path patterns logic
  • review Middleware logic
  • websocket support(maybe)
  • coverage
  • typing support in TY
  • some examples
  • Problem: how to authenticate users?
  • Problem: how to send files?
  • Problem: how to work with cookies?
  • https://jcristharif.com/msgspec/perf-tips.html

CONTRIBUTING

see CONTRIBUTING.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rapis-0.0.4.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rapis-0.0.4-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file rapis-0.0.4.tar.gz.

File metadata

  • Download URL: rapis-0.0.4.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rapis-0.0.4.tar.gz
Algorithm Hash digest
SHA256 55381652e98f77dcf4a692cc6051ba5b4a48633267162369ac89858c76bf62d1
MD5 eff251a4eac3844a1d90fcad0537f40a
BLAKE2b-256 d5e03064d888e7ebfd315a17b8a1c791450bf670e982bcf202efe2df833aff09

See more details on using hashes here.

Provenance

The following attestation bundles were made for rapis-0.0.4.tar.gz:

Publisher: python-publish.yml on sheptalo/rapis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rapis-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: rapis-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rapis-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fd170007c8c1eba91fffe71a6ae9142d786169f463cf55ae1867008941d7ae86
MD5 32a317f8b219b95bf778e1a78a337c5d
BLAKE2b-256 66b4800c3436fbbda7773d891452f7ddbcb5b94d51a06db4f2d2c99b6dcc0a4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rapis-0.0.4-py3-none-any.whl:

Publisher: python-publish.yml on sheptalo/rapis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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