saikub commited on
Commit
8e1f2c1
·
verified ·
1 Parent(s): 1568133

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +7 -1
server.py CHANGED
@@ -30,11 +30,17 @@ def login():
30
 
31
  @app.route('/gradio')
32
  def gradio_app():
 
 
 
 
33
  return redirect("http://localhost:7860")
34
 
35
  def run_gradio():
36
  subprocess.run(["python", "app_w_lora.py"])
37
 
 
 
 
38
  if __name__ == "__main__":
39
- threading.Thread(target=run_gradio).start()
40
  app.run(host='0.0.0.0', port=5000)
 
30
 
31
  @app.route('/gradio')
32
  def gradio_app():
33
+ # This will ensure the app runs only once and not on every request
34
+ if not gradio_app.started:
35
+ threading.Thread(target=run_gradio).start()
36
+ gradio_app.started = True
37
  return redirect("http://localhost:7860")
38
 
39
  def run_gradio():
40
  subprocess.run(["python", "app_w_lora.py"])
41
 
42
+ # Initialize the flag to indicate if the Gradio app has started
43
+ gradio_app.started = False
44
+
45
  if __name__ == "__main__":
 
46
  app.run(host='0.0.0.0', port=5000)