-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (51 loc) · 1.55 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import uvicorn
import colorama
try:
import winloop
except ImportError:
winloop = None
from src.config import conf
from src.logger import logger
if __name__ == '__main__':
if winloop is not None:
winloop.install()
logger.info('winloop is enabled!')
colorama.init()
is_debug = conf.safe.DEBUG
uvicorn.run(
"src.app:app",
reload=is_debug,
host=conf.web.host,
port=conf.web.port,
workers=conf.web.workers,
proxy_headers=bool(conf.web.forward_ip),
forwarded_allow_ips=conf.web.forward_ip,
log_config={
"version": 1,
"disable_existing_loggers": True,
"formatters": {
"default": {"()": "uvicorn.logging.DefaultFormatter", "fmt": "%(levelprefix)s %(message)s"},
},
"handlers": {
"default": {"class": "src.logger.InterceptHandler"},
"access": {
"formatter": "default",
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
},
},
"loggers": {
"uvicorn": {
"handlers": ["default"],
"level": "INFO",
"propagate": False,
},
"uvicorn.error": {"level": "INFO"},
"uvicorn.access": {
"handlers": ["default"],
"level": "INFO",
"propagate": False,
}
}
}
)