-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
40 lines (29 loc) · 929 Bytes
/
app.py
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
40
import logging
import uvicorn
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.middleware import Middleware
from src.middleware.Logging import LoggingMiddleware
from src.ErrorHandler import exception_handlers
from src.routes.v1 import v1
from src.routes.graphql import graphql_route
from src import settings
from src.middleware.Authentication import JWTAuthMiddleware
from starlette.middleware.authentication import AuthenticationMiddleware
routes = [
v1,
graphql_route
]
middleware = [
Middleware(LoggingMiddleware),
Middleware(AuthenticationMiddleware, backend=JWTAuthMiddleware())
]
app = Starlette(
debug=settings.DEBUG,
routes=routes,
exception_handlers=exception_handlers,
middleware=middleware
)
# Start server
if __name__ == '__main__':
uvicorn.run('app:app', host='0.0.0.0', port=8000, log_level='info', reload=True)