-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (23 loc) · 916 Bytes
/
main.py
File metadata and controls
28 lines (23 loc) · 916 Bytes
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
# ------------------------------------------------------------------------------
# Main
# ------------------------------------------------------------------------------
from contextlib import asynccontextmanager
import logging
from typing import AsyncIterator
from fastapi import FastAPI
from routes import player_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)