Settings
This commit is contained in:
17
main.py
17
main.py
@ -1,5 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
import uvicorn
|
||||
from litestar import Litestar
|
||||
from litestar.contrib.repository.exceptions import (
|
||||
RepositoryError as RepositoryException,
|
||||
@ -7,10 +8,13 @@ from litestar.contrib.repository.exceptions import (
|
||||
from litestar.openapi import OpenAPIConfig
|
||||
|
||||
from app.controllers import create_router
|
||||
from app.lib import exceptions, sqlalchemy_plugin
|
||||
from app.lib import exceptions, settings, sqlalchemy_plugin
|
||||
from app.lib.service import ServiceError
|
||||
|
||||
|
||||
def create_app(**kwargs: Any) -> Litestar:
|
||||
kwargs.setdefault("debug", settings.app.DEBUG)
|
||||
|
||||
return Litestar(
|
||||
route_handlers=[create_router()],
|
||||
openapi_config=OpenAPIConfig(title="My API", version="1.0.0"),
|
||||
@ -20,9 +24,18 @@ def create_app(**kwargs: Any) -> Litestar:
|
||||
RepositoryException: exceptions.repository_exception_to_http_response, # type: ignore[dict-item]
|
||||
ServiceError: exceptions.service_exception_to_http_response, # type: ignore[dict-item]
|
||||
},
|
||||
debug=True,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(
|
||||
app,
|
||||
host=settings.server.HOST,
|
||||
log_level=settings.server.LOG_LEVEL,
|
||||
port=settings.server.PORT,
|
||||
reload=settings.server.RELOAD,
|
||||
timeout_keep_alive=settings.server.KEEPALIVE,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user