-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_app.py
More file actions
33 lines (27 loc) · 830 Bytes
/
Copy pathstart_app.py
File metadata and controls
33 lines (27 loc) · 830 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
import argparse
import uvicorn
from dotenv import set_key
from src.config import Environment
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--env",
type=str,
choices=[e.value for e in Environment],
default=None,
help="Environment to start the app in (local, development, staging, production)",
)
args = parser.parse_args()
"""
Passthrough desired environment by writing it to .env
This allows us to still load the correct settings when
uvicorn spawns FastAPI app in a different process.
"""
set_key(dotenv_path=".env", key_to_set="ENVIRONMENT", value_to_set=args.env)
uvicorn.run(
"src.app:app",
host="127.0.0.1",
port=8000,
reload=True,
log_level="debug",
)