rabie54654 commited on
Commit
0122af1
·
1 Parent(s): 560a81c

Hide uvicorn in subprocess to bypass ZeroGPU

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -37,5 +37,6 @@ with gr.Blocks() as demo:
37
  app = gr.mount_gradio_app(fastapi_app, demo, path="/gradio")
38
 
39
  if __name__ == "__main__":
40
- port = int(os.getenv("PORT", "7860"))
41
- uvicorn.run(app, host="0.0.0.0", port=port)
 
 
37
  app = gr.mount_gradio_app(fastapi_app, demo, path="/gradio")
38
 
39
  if __name__ == "__main__":
40
+ port = os.getenv("PORT", "7860")
41
+ # Use subprocess to run Uvicorn to hide it from ZeroGPU's patcher
42
+ subprocess.Popen([sys.executable, "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", port]).wait()