-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
49 lines (38 loc) · 1.14 KB
/
server.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
#!/usr/bin/env python3
import os
from loguru import logger
from dotenv import load_dotenv
load_dotenv()
logger.add(
"secrets_manager.log",
enqueue=True,
colorize=False,
level="WARNING",
rotation="8 MB",
format="{time:DD-MM-YYYY HH:mm:ss} {level} {message}",
)
def strtobool(val: str) -> bool:
"""Convert a string representation of truth to True or False.
True values are 'y', 'yes', 't', 'true', 'on', and '1';
False values are 'n', 'no', 'f', 'false', 'off', and '0'.
Raises ValueError if 'val' is anything else.
"""
val = val.lower().strip()
if val in ("y", "yes", "t", "true", "on", "1"):
return True
elif val in ("n", "no", "f", "false", "off", "0"):
return False
else:
logger.warning(f"invalid truth value {val!r}")
return False
def init_app():
from Api.api import app
app.run(
debug=strtobool(os.getenv("DEBUG", "False")),
host=os.environ.get("BIND_HOST", "0.0.0.0"),
port=os.environ.get("PORT", 5000),
use_reloader=True,
)
if __name__ == "__main__":
logger.info("Starting Secrets Manager")
init_app()