-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (30 loc) · 1.08 KB
/
main.py
File metadata and controls
39 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Main application module for the FastAPI RESTful API.
- Sets up the FastAPI app with metadata (title, description, version).
- Defines the lifespan event handler for app startup/shutdown logging.
- Includes API routers for player and health endpoints.
This serves as the entry point for running the API server.
"""
from contextlib import asynccontextmanager
import logging
from typing import AsyncIterator
from fastapi import FastAPI
from routes import player_route, health_route
# https://github.com/encode/uvicorn/issues/562
UVICORN_LOGGER = "uvicorn.error"
logger = logging.getLogger(UVICORN_LOGGER)
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
"""
Lifespan event handler for FastAPI.
"""
logger.info("Lifespan event handler execution complete.")
yield
app = FastAPI(
lifespan=lifespan,
title="python-samples-fastapi-restful",
description="🧪 Proof of Concept for a RESTful API made with Python 3 and FastAPI",
version="1.0.0",
)
app.include_router(player_route.api_router)
app.include_router(health_route.api_router)