-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.py
53 lines (46 loc) · 1.46 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
import requests
import json
def send_start_test(test_config):
# Assuming your Flask API is running on localhost and port 5000
response = requests.post("http://localhost:5000/start_test", json=test_config)
try:
st.success(print(response.content))
# result = response.json()
return response.content
except json.decoder.JSONDecodeError:
return None
def send_stop_test():
response = requests.post("http://localhost:5000/stop_test")
try:
result = response.json()
return result
except json.decoder.JSONDecodeError:
return None
def get_metrics():
response = requests.get("http://localhost:5000/metrics")
try:
metrics = response.json()
return metrics
except json.decoder.JSONDecodeError:
return None
st.title('Orchestrator Control Panel')
if st.button('Start Test'):
test_config = {} # Add your test configuration parameters here
result = send_start_test(test_config)
if result is not None:
st.write(result)
else:
st.write("Error: Failed to parse response as JSON")
if st.button('Stop Test'):
result = send_stop_test()
if result is not None:
st.write(result)
else:
st.write("Error: Failed to parse response as JSON")
if st.button('Show Metrics'):
metrics = get_metrics()
if metrics is not None:
st.json(metrics)
else:
st.write("Error: Failed to parse response as JSON")