GoodLuckChuck commited on
Commit
c3ff92a
·
verified ·
1 Parent(s): 0432cd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -1102,7 +1102,7 @@ with gr.Blocks() as demo:
1102
 
1103
  gr.LoginButton()
1104
  run_button = gr.Button("Process Questions")
1105
- status_output = gr.Textbox(label="Status", lines=4) # Increased lines for better visibility
1106
  results_table = gr.DataFrame(
1107
  headers=['Task ID', 'Question', 'Answer', 'Confidence', 'Processing Time'],
1108
  label="Results"
@@ -1113,9 +1113,12 @@ with gr.Blocks() as demo:
1113
  outputs=[status_output, results_table]
1114
  )
1115
 
1116
- # Add FastAPI endpoint to mount Gradio
1117
  app = gr.mount_gradio_app(app, demo, path="/")
1118
 
 
 
 
1119
  if __name__ == "__main__":
1120
  import uvicorn
1121
 
@@ -1126,12 +1129,11 @@ if __name__ == "__main__":
1126
  # Get port from environment variable or default to 7860 (standard HF Spaces port)
1127
  port = int(os.environ.get("PORT", 7860))
1128
 
1129
- # Run the server with explicit host and port
1130
  uvicorn.run(
1131
- "improved_agent:app", # Use string reference instead of app instance
1132
- host="0.0.0.0", # Required for HF Spaces
1133
  port=port,
1134
  log_config=log_config,
1135
- log_level="info",
1136
- reload=False # Disable reload in production
1137
  )
 
1102
 
1103
  gr.LoginButton()
1104
  run_button = gr.Button("Process Questions")
1105
+ status_output = gr.Textbox(label="Status", lines=4)
1106
  results_table = gr.DataFrame(
1107
  headers=['Task ID', 'Question', 'Answer', 'Confidence', 'Processing Time'],
1108
  label="Results"
 
1113
  outputs=[status_output, results_table]
1114
  )
1115
 
1116
+ # Mount Gradio app to FastAPI
1117
  app = gr.mount_gradio_app(app, demo, path="/")
1118
 
1119
+ # Explicitly define the ASGI application
1120
+ application = app
1121
+
1122
  if __name__ == "__main__":
1123
  import uvicorn
1124
 
 
1129
  # Get port from environment variable or default to 7860 (standard HF Spaces port)
1130
  port = int(os.environ.get("PORT", 7860))
1131
 
1132
+ # Run the server
1133
  uvicorn.run(
1134
+ app, # Use the app instance directly
1135
+ host="0.0.0.0",
1136
  port=port,
1137
  log_config=log_config,
1138
+ log_level="info"
 
1139
  )