miniapi like fastapi
Project description
MiniAPI3
A lightweight Python web framework inspired by FastAPI, featuring async support, WebSocket capabilities, and middleware.
github repo
Features
- Async request handling
- Route parameters
- WebSocket support
- Middleware system
- Request validation
- CORS support
- Form data handling
- ASGI compatibility
Installation
pip install miniapi3
For WebSocket support:
pip install miniapi3[websockets]
Quick Start
# main.py
from miniapi3 import MiniAPI, Request
app = MiniAPI()
@app.get("/")
async def hello():
return {"message": "Hello, World!"}
@app.get("/users/{user_id}")
async def get_user(request: Request):
user_id = request.path_params["user_id"]
return {"user_id": user_id}
# WebSocket example
@app.websocket("/ws")
async def websocket_handler(ws):
while True:
message = await ws.receive()
await ws.send(f"Echo: {message}")
if __name__ == "__main__":
app.run()
uvicorn support
uvicorn main:app
Request Validation
pip install pydantic
from miniapi3 import MiniAPI
from pydantic import BaseModel
app = MiniAPI()
class UserCreate(BaseModel):
name: str
@app.post("/users")
async def create_user(user: UserCreate):
return dict(user)
CORS Middleware
from miniapi3 import MiniAPI, CORSMiddleware
app = MiniAPI()
app.add_middleware(CORSMiddleware, allow_origins=["*"])
HTML Response
from miniapi3 import MiniAPI, html
app = MiniAPI()
@app.get("/")
async def index():
return html("<h1>Hello, World!</h1>")
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
miniapi3-0.1.7.tar.gz
(10.9 kB
view details)
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
miniapi3-0.1.7-py3-none-any.whl
(12.7 kB
view details)
File details
Details for the file miniapi3-0.1.7.tar.gz.
File metadata
- Download URL: miniapi3-0.1.7.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88a63d5f8a20c02a81a41773f4af3c61cb16cf69565df5b4502fd77daef9428e
|
|
| MD5 |
dab116cd7d5dd47edde35f9762ad64be
|
|
| BLAKE2b-256 |
c346dd1a2142f17862068d0f4fe9af0768a2f294a9f54c89608f72405c3ad2a2
|
File details
Details for the file miniapi3-0.1.7-py3-none-any.whl.
File metadata
- Download URL: miniapi3-0.1.7-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62e0af35dce85febc3d8b97b161d2b745caa99c8ec635c23b94c09decb4193c7
|
|
| MD5 |
bed819971de757ae753b66584a22ef38
|
|
| BLAKE2b-256 |
c0603a480fc1a5b5aeff305dc483ec8ae37bbc7e7b704e04a2d9cde4b63aa434
|