Buckets:
AnonymousSpottedToad/human_verified_bucket / codebase /python /nijaru_zenith /docs /benchmarks /zenith_minimal.py
| """Minimal Zenith benchmark application.""" | |
| import os | |
| from pydantic import BaseModel | |
| # Set required env var | |
| os.environ["SECRET_KEY"] = "benchmark-secret-key-for-testing" | |
| from zenith import Zenith | |
| class CreateUserModel(BaseModel): | |
| name: str | |
| email: str | |
| # Simple in-memory storage | |
| users_db = {} | |
| for i in range(100): | |
| users_db[i] = { | |
| "id": i, | |
| "name": f"User {i}", | |
| "email": f"user{i}@example.com", | |
| "created_at": "2025-01-01T00:00:00", | |
| } | |
| # App - disable debug to avoid middleware overhead in benchmarks | |
| app = Zenith(debug=False) | |
| # Routes | |
| async def hello_world(): | |
| return {"message": "Hello, World!"} | |
| async def get_user(user_id: int): | |
| if user_id in users_db: | |
| return users_db[user_id] | |
| return {"error": "User not found"} | |
| async def list_users(limit: int = 100): | |
| return list(users_db.values())[:limit] | |
| async def create_user(data: CreateUserModel): | |
| new_id = len(users_db) | |
| users_db[new_id] = { | |
| "id": new_id, | |
| "name": data.name, | |
| "email": data.email, | |
| "created_at": "2025-01-01T00:00:00", | |
| } | |
| return users_db[new_id] | |
| async def protected_route(): | |
| return {"user": {"id": 1, "email": "test@example.com"}} | |
| async def validate_data(data: CreateUserModel): | |
| return {"validated": True, "data": data.model_dump()} | |
| async def upload_file(): | |
| return {"size": 10000, "message": "File processed"} | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="127.0.0.1", port=8100, log_level="error") | |
Xet Storage Details
- Size:
- 1.68 kB
- Xet hash:
- 3f25ae798a54f3acec0f83fa2ad12d8c355de6c9563f551e4c55d102a59dc82a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.