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.6.tar.gz
(11.0 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.6-py3-none-any.whl
(12.8 kB
view details)
File details
Details for the file miniapi3-0.1.6.tar.gz.
File metadata
- Download URL: miniapi3-0.1.6.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.21.0 CPython/3.11.10 Darwin/24.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57b57aff451ad08d23e90034671e698d5b9fee9cc48746d8f79f4b226932706b
|
|
| MD5 |
64ff32d39d5dce545945be48befc4e2c
|
|
| BLAKE2b-256 |
fbbce4e65404cef4dfc84f475b62a59e3a7679797047afc6491a42260cbb712d
|
File details
Details for the file miniapi3-0.1.6-py3-none-any.whl.
File metadata
- Download URL: miniapi3-0.1.6-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.21.0 CPython/3.11.10 Darwin/24.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae5df45ee9d4f1f0c7194ed80d924682e09671739de7987bd06a4c79576735ad
|
|
| MD5 |
0ba5d000c48e1154ffde7579debbfe1f
|
|
| BLAKE2b-256 |
47d6a9d4441366a44a31d176cd85cc3f33fea74a8e598067d692df364ed20302
|