1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
from litestar import Litestar, get
from litestar.logging.config import LoggingConfig
from litestar.middleware.logging import LoggingMiddlewareConfig
@get("/")
async def handler() -> dict[str, str]:
return {"hello": "world"}
logging_middleware_config = LoggingMiddlewareConfig()
app = Litestar(
route_handlers=[handler],
logging_config=LoggingConfig(),
middleware=[logging_middleware_config.middleware],
)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app)
|