CalebCometML commited on
Commit
5faac1a
·
1 Parent(s): 10c35cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -12
app.py CHANGED
@@ -42,14 +42,6 @@ def _is_running(kangas=False, streamlit=False):
42
  @application.route('/kangas', strict_slashes=False)
43
  @application.route('/kangas/<path:path>')
44
  def kangas_proxy(path=None):
45
- if kg._is_running("node", "kangas"):
46
- application.logger.info("Kangas is running on fetch")
47
- else:
48
- application.logger.info("Kangas is not running on fetch")
49
- application.logger.info("Trying to launch Kangas now")
50
- subprocess.call(["kangas", "server", "--frontend-port", "7640", "--frontend-root", "kangas"])
51
- #kg.launch(host=ip_address, port=7640, debug="DEBUG")
52
-
53
  query_string = request.query_string.decode('utf-8')
54
 
55
  if path is None and len(query_string) < 1:
@@ -96,16 +88,39 @@ def image_proxy(path=None):
96
 
97
  @application.route('/')
98
  def streamlit():
99
- streamlit_runs = _is_running(False, True)
100
- if streamlit_runs is False:
101
- application.logger.info("Streamlit is not running yet")
102
- #subprocess.call(["streamlit", "run", "streamlitapp.py", "--server.port", "7840"])
103
  resp = requests.get(f'http://{ip_address}:7840/')
104
  excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
105
  headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers]
106
  response = Response(resp.content, resp.status_code, headers)
107
  application.logger.info(response)
108
  return response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  if __name__ == "__main__":
111
  streamlit_runs = _is_running(False, True)
 
42
  @application.route('/kangas', strict_slashes=False)
43
  @application.route('/kangas/<path:path>')
44
  def kangas_proxy(path=None):
 
 
 
 
 
 
 
 
45
  query_string = request.query_string.decode('utf-8')
46
 
47
  if path is None and len(query_string) < 1:
 
88
 
89
  @application.route('/')
90
  def streamlit():
 
 
 
 
91
  resp = requests.get(f'http://{ip_address}:7840/')
92
  excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
93
  headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers]
94
  response = Response(resp.content, resp.status_code, headers)
95
  application.logger.info(response)
96
  return response
97
+
98
+ @application.route('/static/<path:path>')
99
+ def streamlit_static(path):
100
+ resp = requests.get(f'http://{ip_address}:7840/static/{path}')
101
+ excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
102
+ headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers]
103
+ response = Response(resp.content, resp.status_code, headers)
104
+ application.logger.info(response)
105
+ return response
106
+
107
+ @application.route('/vendor/<path:path>')
108
+ def streamlit_vendor(path):
109
+ resp = requests.get(f'http://{ip_address}:7840/vendor/{path}')
110
+ excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
111
+ headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers]
112
+ response = Response(resp.content, resp.status_code, headers)
113
+ application.logger.info(response)
114
+ return response
115
+
116
+ @application.route('/_stcore/<path:path>')
117
+ def streamlit_stcore(path):
118
+ resp = requests.get(f'http://{ip_address}:7840/_stcore/{path}')
119
+ excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
120
+ headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers]
121
+ response = Response(resp.content, resp.status_code, headers)
122
+ application.logger.info(response)
123
+ return response
124
 
125
  if __name__ == "__main__":
126
  streamlit_runs = _is_running(False, True)