-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
36 lines (32 loc) · 955 Bytes
/
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
import os
import uvicorn
from dotenv import load_dotenv
from scripts.ssl.generate_ssl import generate_certificate
load_dotenv()
if __name__ == "__main__":
ssl_path = "scripts/ssl/"
generate_certificate(path=ssl_path)
ssl_keyfile = ssl_path + "key.pem"
ssl_certfile = ssl_path + "cert.pem"
if os.getenv("ENV") == "development":
# Development
# Run the server
uvicorn.run(
app="src:app",
host="0.0.0.0",
port=int(os.getenv("PORT") or 5000),
log_level="debug",
reload=True, # reload the server every time code changes
)
else:
# Production
# Run the server
uvicorn.run(
app="src:app",
host="0.0.0.0",
port=int(os.getenv("PORT") or 5000),
log_level="error",
workers=2,
ssl_keyfile=ssl_keyfile,
ssl_certfile=ssl_certfile,
)