-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (32 loc) · 888 Bytes
/
main.py
File metadata and controls
43 lines (32 loc) · 888 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
""" Small FastApi micro-service. """
# See:
# https://fastapi.tiangolo.com
# https://fastapi.tiangolo.com/tutorial/
import logging
import logging_tree
from fastapi import FastAPI
import middleware
import controllers
DEFAULT_LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"stream": "ext://sys.stderr",
},
},
"loggers": {
"": {"level": "INFO", "handlers": ["console"]},
},
}
logging.config.dictConfig(DEFAULT_LOGGING)
FASTAPI_ENV = os.environ.get("FASTAPI_ENV", "production")
if FASTAPI_ENV == "development":
# to see the current log config:
logging_tree.printout()
app = FastAPI()
middleware.add_log_requests(app)
middleware.add_log_exceptions(app)
controllers.mount_controllers(app)