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.5.tar.gz
(10.7 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.5-py3-none-any.whl
(12.5 kB
view details)
File details
Details for the file miniapi3-0.1.5.tar.gz.
File metadata
- Download URL: miniapi3-0.1.5.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.20.1 CPython/3.11.10 Darwin/24.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f21ee2f2af1fa65751e18c3f3561babdcc0db938c56ecc5e101cf9d2db071cda
|
|
| MD5 |
42d0fc705cc6f0a9adcf4067265e0c2a
|
|
| BLAKE2b-256 |
b8fd76958a3b27ccd0f4a147dfd698ebdf084b12603f557077a1dc63b6db05cb
|
File details
Details for the file miniapi3-0.1.5-py3-none-any.whl.
File metadata
- Download URL: miniapi3-0.1.5-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.20.1 CPython/3.11.10 Darwin/24.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81493a2d619bc825d49495d16f2dd076666b1dbfe3d36df390965a744912d80a
|
|
| MD5 |
fb4b91a18bb14ade5bd2096fdac3b626
|
|
| BLAKE2b-256 |
2b9a95a818b37f2268010efdfd933386cdd7b7d4cb0b2d1708c008a17c168b7a
|