Buckets:
AnonymousSpottedToad/human_verified_bucket / codebase /python /nijaru_zenith /docs /examples /00-hello-world.py
| """ | |
| ๐ Zenith Hello World - The Simplest Possible Example | |
| This is your first Zenith application. It demonstrates: | |
| - Creating a Zenith app | |
| - Defining routes | |
| - Running the server | |
| Run with: python examples/00-hello-world.py | |
| Then visit: http://localhost:8000 | |
| """ | |
| from zenith import Zenith | |
| # Create the Zenith application in debug mode (auto-generates SECRET_KEY) | |
| app = Zenith(debug=True) | |
| # Define a simple route | |
| async def hello_world(): | |
| """Simple hello world endpoint.""" | |
| return { | |
| "message": "Hello, World! ๐", | |
| "framework": "Zenith", | |
| "version": "1.0.0", | |
| "docs": "/docs", | |
| } | |
| async def hello_name(name: str): | |
| """Personalized greeting with path parameter.""" | |
| return { | |
| "message": f"Hello, {name}! ๐", | |
| "framework": "Zenith", | |
| "timestamp": "2025-09-09T00:00:00Z", | |
| } | |
| async def health_check(): | |
| """Health check endpoint.""" | |
| return { | |
| "status": "healthy", | |
| "message": "Zenith is running perfectly! โ ", | |
| "framework": "Zenith", | |
| "example": "00-hello-world", | |
| } | |
| if __name__ == "__main__": | |
| print("๐ Starting Zenith Hello World Example") | |
| print("๐ Server will start at: http://localhost:8001") | |
| print("๐ Try these endpoints:") | |
| print(" GET / - Hello World with framework info") | |
| print(" GET /hello/you - Personalized greeting with path param") | |
| print(" GET /health - Health check endpoint") | |
| print("๐ Interactive docs: http://localhost:8001/docs") | |
| print() | |
| print("๐จ This example demonstrates:") | |
| print(" โข Basic Zenith application setup") | |
| print(" โข Route definition with decorators") | |
| print(" โข Path parameters and type hints") | |
| print(" โข JSON response handling") | |
| print(" โข Automatic API documentation") | |
| print() | |
| import uvicorn | |
| uvicorn.run(app, host="127.0.0.1", port=8001) | |
Xet Storage Details
- Size:
- 1.97 kB
- Xet hash:
- 488b1dada00cbac550c5e6ec936074fbcb0121ff1eadaed238d36b1f6c503dda
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.