Danil commited on
Commit
137db73
Β·
1 Parent(s): 7ec2ca3
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -4,13 +4,19 @@ import os
4
  import json
5
 
6
  def start_server():
7
- os.system("uvicorn server:app --port 8080 --host 0.0.0.0 --workers 2")
8
  st.session_state['server_started'] = True
9
-
 
 
 
 
 
10
  if 'server_started' not in st.session_state:
11
- start_server()
12
- print('statret')
13
- st.session_state['server_started'] = True
 
14
 
15
  st.set_page_config(
16
  page_title="Incoder Example",
 
4
  import json
5
 
6
  def start_server():
7
+ os.system("uvicorn inference_server:app --port 8080 --host 0.0.0.0 --workers 2")
8
  st.session_state['server_started'] = True
9
+
10
+ def is_port_in_use(port):
11
+ import socket
12
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
13
+ return s.connect_ex(('0.0.0.0', port)) == 0
14
+
15
  if 'server_started' not in st.session_state:
16
+ st.session_state['server_started'] = False
17
+
18
+ if not st.session_state['server_started']:
19
+ start_server()
20
 
21
  st.set_page_config(
22
  page_title="Incoder Example",