A minimal ASGI web framework for Python.
Project description
SerPy
SerPy is a minimal, modern, and lightning-fast ASGI web framework for Python. It is designed for simplicity, flexibility, and performance, making it ideal for building APIs, microservices, and web applications with minimal overhead.
Table of Contents
- Features
- Installation
- Quick Start
- Example Project
- Middleware
- Advanced Routing
- Contributing
- Running Locally
- License
- Contact
Features
- ASGI compatible: Works seamlessly with ASGI servers like Uvicorn and Hypercorn
- Simple routing: Path parameters, method-based routing, and easy route registration
- Middleware support: Add custom middleware for logging, authentication, CORS, etc.
- Request/Response abstraction: Clean API for handling requests and responses
- Modular: Use routers to organize your application
- Type hints: Modern Pythonic code with type hints
Installation
Install the latest release from PyPI:
pip install serpy-rest
Or, to use the latest development version, clone this repository:
git clone https://github.com/ragav2005/SerPy.git
cd SerPy
pip install .
Quick Start
Create a file called main.py:
from serpy import SerPy, Response
app = SerPy()
@app.route("/hello/{name}", methods=["GET"])
async def hello(request, name):
return Response({"message": f"Hello, {name}!"})
# Run with: uvicorn main:app
Start the server:
uvicorn main:app --reload
Example Project Structure
myproject/
├── main.py
├── requirements.txt
└── ...
Middleware
Add global middleware to your app:
async def log_middleware(request, call_next):
print(f"Request: {request.method} {request.path}")
response = await call_next(request)
return response
app.add_middleware(log_middleware)
Advanced Routing
Use routers to organize endpoints:
from serpy import Router
user_router = Router()
@user_router.route("/users/{user_id}", methods=["GET"])
async def get_user(request, user_id):
# Fetch user logic here
return Response({"user_id": user_id})
app.include_router(user_router, prefix="/api")
Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes
- Push to your fork and submit a pull request
Please ensure your code follows PEP8 and includes tests where appropriate.
Running Locally (Development)
- Clone the repository:
git clone https://github.com/ragav2005/SerPy.git cd SerPy
- (Optional) Create a virtual environment:
python3 -m venv .venv source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run the example app or your own app with Uvicorn:
uvicorn main:app --reload
License
This project is licensed under the MIT License.
Contact
Author: ragav2005 For questions, suggestions, or issues, please open an issue on GitHub.
Project details
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file serpy_rest-0.1.1.tar.gz.
File metadata
- Download URL: serpy_rest-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f5fa265aff7a288007348ee0eb30bf9793b9283ad85feec85068c24820f3d9d
|
|
| MD5 |
02bf55be6655c491637b59f897138319
|
|
| BLAKE2b-256 |
5e4d63528ba168c1bde0ad9f8791de0c7c0b13e5738c8e7b573d23c0e6cc0459
|
File details
Details for the file serpy_rest-0.1.1-py3-none-any.whl.
File metadata
- Download URL: serpy_rest-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aa80f5eb2dcb371ac90f45f3d0ba2ff4bde080af25630efef4ba79af7ff9e4b
|
|
| MD5 |
7ec70be7d5bf12863a92ea975291c92c
|
|
| BLAKE2b-256 |
d6bd74a6b09ee24d1cdfb1d1ae18896febbee0cf244cb54696f4120a314f36e8
|