BEASTZZZ commited on
Commit
e06ff4a
·
verified ·
1 Parent(s): 5ac7688

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -750,7 +750,17 @@ with gr.Blocks(title="JanMat backend status") as demo:
750
  "The Next.js frontend and the GitHub Actions cron talk "
751
  "to the FastAPI routes on this Space, not to this page.")
752
  refresh_btn = gr.Button("Refresh status")
753
- status_box = gr.Textbox(label="Status", lines=6, value=_status_snapshot)
 
 
 
 
 
 
 
 
 
 
754
  refresh_btn.click(fn=_status_snapshot, outputs=status_box)
755
 
756
  # Mount the FastAPI app's real routes onto the same ASGI app the Gradio
@@ -762,4 +772,4 @@ app = gr.mount_gradio_app(app, demo, path="/ui")
762
 
763
  if __name__ == "__main__":
764
  import uvicorn
765
- uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 7860)))
 
750
  "The Next.js frontend and the GitHub Actions cron talk "
751
  "to the FastAPI routes on this Space, not to this page.")
752
  refresh_btn = gr.Button("Refresh status")
753
+ # Static initial text — NOT a callable. Passing a callable here gets
754
+ # evaluated the moment this Blocks object is constructed, i.e. at
755
+ # Space boot, which fires the @spaces.GPU-decorated function before
756
+ # the server has even started listening. That collides with ZeroGPU's
757
+ # own worker-process setup and crashes the Space with "address
758
+ # already in use" on 7860. The status/GPU check must only run in
759
+ # response to an actual click, never automatically at import time.
760
+ status_box = gr.Textbox(
761
+ label="Status", lines=6,
762
+ value="Click \"Refresh status\" to check.",
763
+ )
764
  refresh_btn.click(fn=_status_snapshot, outputs=status_box)
765
 
766
  # Mount the FastAPI app's real routes onto the same ASGI app the Gradio
 
772
 
773
  if __name__ == "__main__":
774
  import uvicorn
775
+ uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 7860)))