qqwjq1981 commited on
Commit
7eddca9
·
verified ·
1 Parent(s): 17c8ed9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -781,7 +781,7 @@ shared_state = {"project_desc_table": pd.DataFrame(), "task_analysis_txt": "", "
781
 
782
  # Button Action: Fetch State
783
  def fetch_updated_state():
784
- response = requests.get("http://localhost:7860/state")
785
  # Check the status code and the raw response
786
  if response.status_code == 200:
787
  try:
@@ -1150,7 +1150,7 @@ logging.debug(f"Gradio version: {gr.__version__}")
1150
  logging.debug(f"FastAPI version: {fastapi.__version__}")
1151
 
1152
  # Mount the Gradio ASGI app at "/gradio"
1153
- app.mount("/", gradio_asgi_app)
1154
 
1155
  # create a static directory to store the static files
1156
  static_dir = Path('./static')
@@ -1168,14 +1168,12 @@ app.mount("/static", StaticFiles(directory=static_dir), name="static")
1168
  # else:
1169
  # logging.error(f"Gradio assets directory not found at: {gradio_assets_path}")
1170
 
1171
- # # Redirect from the root endpoint to the Gradio app
1172
- # @app.get("/", response_class=RedirectResponse)
1173
- # async def index():
1174
- # return {"message": "FastAPI is running. Visit /gradio for the Gradio interface."}
1175
-
1176
- # return RedirectResponse(url="/gradio", status_code=307)
1177
 
1178
  # Run the FastAPI server using uvicorn
1179
  if __name__ == "__main__":
1180
- port = int(os.getenv("PORT", 7860)) # Default to 7860 if PORT is not set
1181
  uvicorn.run(app, host="0.0.0.0", port=port)
 
781
 
782
  # Button Action: Fetch State
783
  def fetch_updated_state():
784
+ response = requests.get("http://localhost:5000/state")
785
  # Check the status code and the raw response
786
  if response.status_code == 200:
787
  try:
 
1150
  logging.debug(f"FastAPI version: {fastapi.__version__}")
1151
 
1152
  # Mount the Gradio ASGI app at "/gradio"
1153
+ app.mount("/gradio", gradio_asgi_app)
1154
 
1155
  # create a static directory to store the static files
1156
  static_dir = Path('./static')
 
1168
  # else:
1169
  # logging.error(f"Gradio assets directory not found at: {gradio_assets_path}")
1170
 
1171
+ # Redirect from the root endpoint to the Gradio app
1172
+ @app.get("/", response_class=RedirectResponse)
1173
+ async def index():
1174
+ return RedirectResponse(url="/gradio", status_code=307)
 
 
1175
 
1176
  # Run the FastAPI server using uvicorn
1177
  if __name__ == "__main__":
1178
+ port = int(os.getenv("PORT", 5000)) # Default to 7860 if PORT is not set
1179
  uvicorn.run(app, host="0.0.0.0", port=port)