Ken Sang Tang commited on
Commit
734b1b2
·
verified ·
1 Parent(s): 031fc1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -16,12 +16,20 @@ from pydantic import BaseModel
16
  from loguru import logger
17
  import uvicorn
18
  import aiohttp
 
19
 
20
  app = FastAPI()
21
 
22
  OPENMANUS_ENDPOINT_URL = os.getenv("OPENMANUS_ENDPOINT_URL")
 
 
 
 
 
 
 
23
  if not OPENMANUS_ENDPOINT_URL:
24
- raise EnvironmentError("OPENMANUS_ENDPOINT_URL environment variable must be set")
25
 
26
  app.mount("/static", StaticFiles(directory="static"), name="static")
27
  templates = Jinja2Templates(directory="templates")
 
16
  from loguru import logger
17
  import uvicorn
18
  import aiohttp
19
+ import toml
20
 
21
  app = FastAPI()
22
 
23
  OPENMANUS_ENDPOINT_URL = os.getenv("OPENMANUS_ENDPOINT_URL")
24
+
25
+ if not OPENMANUS_ENDPOINT_URL:
26
+ config_path = "config/config.toml"
27
+ if os.path.exists(config_path):
28
+ config = toml.load(config_path)
29
+ OPENMANUS_ENDPOINT_URL = config.get("OPENMANUS_ENDPOINT_URL")
30
+
31
  if not OPENMANUS_ENDPOINT_URL:
32
+ raise EnvironmentError("OPENMANUS_ENDPOINT_URL must be set in env or config/config.toml")
33
 
34
  app.mount("/static", StaticFiles(directory="static"), name="static")
35
  templates = Jinja2Templates(directory="templates")