-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (23 loc) · 827 Bytes
/
app.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
import argparse
import uvicorn
from fastapi import FastAPI
from omegaconf import OmegaConf
from src.containers.containers import Container
from src.routes import planets as planets_routes
from src.routes.routers import router as app_router
def create_app() -> FastAPI:
container = Container()
cfg = OmegaConf.load("configs/config.yaml")
container.config.from_dict(cfg)
container.wire([planets_routes])
app = FastAPI()
app.include_router(app_router, prefix="/planets", tags=["planets"])
return app
if __name__ == "__main__":
def arg_parse():
parser = argparse.ArgumentParser()
parser.add_argument("port", type=int, help="port number")
return parser.parse_args()
app = create_app()
args = arg_parse()
uvicorn.run(app, port=args.port, host="127.0.0.1")