IR_PR_PilotPro / run.py
Corin1998's picture
Create run.py
96bcd77 verified
raw
history blame contribute delete
795 Bytes
# run.py
"""
Uvicorn 起動用エントリ。
- 優先して irpr.main を読み込む
- なければ app.main をフォールバックで読み込む
"""
import os
import sys
import importlib
# /code(リポジトリルート)をパスに追加
ROOT = os.path.dirname(os.path.abspath(__file__))
if ROOT not in sys.path:
sys.path.insert(0, ROOT)
last_err = None
app = None
for target in ("irpr.main", "app.main"):
try:
mod = importlib.import_module(target)
app = getattr(mod, "app")
break
except Exception as e:
last_err = e
continue
if app is None:
raise RuntimeError(
"Failed to import FastAPI app from irpr.main or app.main. "
"Make sure one of them exists and defines `app = FastAPI(...)`."
) from last_err