Skip to content

lucamattiazzi/nextpress

Repository files navigation

Nextpress

A Python web framework inspired by Express.js, built on ASGI.

Installation

pip install nextpress

Quick Start

from nextpress import Nextpress, Request, Response, Anext

app = Nextpress()

async def logger(request: Request, response: Response, anext: Anext):
    print(f"{request.method} {request.path}")
    response.set_header("X-Processed-Time", str(time.time()))
    await anext()


async def hello(response: Response[str]):
    await response.send_text("Hello, World!")

app.get("/", logger, hello)

Run with:

uvicorn example:app

Features

  • Express-style routing with <method>() and use()
  • Route based middleware support with anext() pattern
  • Explicit response writing
  • Modular middlewares to parse input
  • Route matching and chaining
  • Built on uvicorn/ASGI for async performance
  • Response and Request generics for typing

Future features (feautures?)

  • Pydantic validation of request and response
  • CORS, multipart/form body parser, and other middlewares
  • Actual tests
  • Websocket handling

About

Another take on an ASGI compliant python web framework

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages