Skip to main content

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

  • 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:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Commit your changes
  4. Push to your fork and submit a pull request

Please ensure your code follows PEP8 and includes tests where appropriate.


Running Locally (Development)

  1. Clone the repository:
    git clone https://github.com/ragav2005/SerPy.git
    cd SerPy
    
  2. (Optional) Create a virtual environment:
    python3 -m venv .venv
    source .venv/bin/activate
    
  3. Install dependencies:
    pip install -r requirements.txt
    
  4. 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


Download files

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

Source Distribution

serpy_rest-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

serpy_rest-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

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

Hashes for serpy_rest-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3f5fa265aff7a288007348ee0eb30bf9793b9283ad85feec85068c24820f3d9d
MD5 02bf55be6655c491637b59f897138319
BLAKE2b-256 5e4d63528ba168c1bde0ad9f8791de0c7c0b13e5738c8e7b573d23c0e6cc0459

See more details on using hashes here.

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

Hashes for serpy_rest-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2aa80f5eb2dcb371ac90f45f3d0ba2ff4bde080af25630efef4ba79af7ff9e4b
MD5 7ec70be7d5bf12863a92ea975291c92c
BLAKE2b-256 d6bd74a6b09ee24d1cdfb1d1ae18896febbee0cf244cb54696f4120a314f36e8

See more details on using hashes here.

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