Sanjayraju30 commited on
Commit
5112b0f
·
verified ·
1 Parent(s): cdc3dbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -2,10 +2,10 @@ import gradio as gr
2
  from fastapi import FastAPI
3
  from risk_model import predict_risk, retrain_model, get_history_df
4
 
5
- # FastAPI backend
6
- app = FastAPI()
7
 
8
- # Gradio UI
9
  gradio_app = gr.Blocks()
10
 
11
  with gradio_app:
@@ -35,9 +35,10 @@ with gradio_app:
35
  predict_btn.click(classify, inputs=[temp, duration], outputs=[result, score, history_table])
36
  retrain_btn.click(retrain_model, outputs=[retrain_output])
37
 
38
- # Mount Gradio UI on FastAPI
39
- @app.get("/")
40
  def root():
41
- return {"message": "Heating Mantle Risk API is live!"}
42
 
43
- app = gr.mount_gradio_app(app, gradio_app, path="/predict-ui")
 
 
2
  from fastapi import FastAPI
3
  from risk_model import predict_risk, retrain_model, get_history_df
4
 
5
+ # Create FastAPI instance
6
+ fastapi_app = FastAPI()
7
 
8
+ # Create Gradio app
9
  gradio_app = gr.Blocks()
10
 
11
  with gradio_app:
 
35
  predict_btn.click(classify, inputs=[temp, duration], outputs=[result, score, history_table])
36
  retrain_btn.click(retrain_model, outputs=[retrain_output])
37
 
38
+ # Optional: basic route to test API is up
39
+ @fastapi_app.get("/")
40
  def root():
41
+ return {"status": "Heating Mantle API is live"}
42
 
43
+ # Hugging Face requires this line exactly
44
+ app = gr.mount_gradio_app(fastapi_app, gradio_app, path="/predict-ui")