Spaces:
Runtime error
Runtime error
File size: 691 Bytes
efd5d73 | 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 | import importlib.util
import os
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
BACKEND_DIR = ROOT / "Backend"
BACKEND_APP = BACKEND_DIR / "app.py"
if str(BACKEND_DIR) not in sys.path:
sys.path.insert(0, str(BACKEND_DIR))
spec = importlib.util.spec_from_file_location("backend_app", BACKEND_APP)
if spec is None or spec.loader is None:
raise RuntimeError(f"Unable to load backend app from {BACKEND_APP}")
backend_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(backend_module)
app = backend_module.app
if __name__ == "__main__":
port = int(os.environ.get("PORT", 7860))
app.run(host="0.0.0.0", port=port, debug=True)
|