Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,12 @@ def get_status(credentials, instance_name):
|
|
25 |
status = True if item["status"] == "RUNNING" else False
|
26 |
return status, ip_address
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
def schedule_server(credentials, instance_name):
|
29 |
service = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
30 |
request = service.instances().setScheduling(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c', instance=instance_name, body={"automaticRestart": False,"maxRunDuration": {"seconds": 7200}})
|
@@ -62,6 +68,8 @@ if not status:
|
|
62 |
response = activate_server(credentials, instance_name)
|
63 |
else:
|
64 |
st.write(f"You can access Lucky Reactor via http://{ip_address}:7860")
|
|
|
|
|
65 |
with st.form("deactivate_form"):
|
66 |
token = st.text_input("Token")
|
67 |
submitted = st.form_submit_button("Terminate 🕊️")
|
|
|
25 |
status = True if item["status"] == "RUNNING" else False
|
26 |
return status, ip_address
|
27 |
|
28 |
+
def get_server(credentials, instance_name):
|
29 |
+
service = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
30 |
+
request = service.instances().get(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c', instance=instance_name)
|
31 |
+
response = request.execute()
|
32 |
+
return response
|
33 |
+
|
34 |
def schedule_server(credentials, instance_name):
|
35 |
service = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
36 |
request = service.instances().setScheduling(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c', instance=instance_name, body={"automaticRestart": False,"maxRunDuration": {"seconds": 7200}})
|
|
|
68 |
response = activate_server(credentials, instance_name)
|
69 |
else:
|
70 |
st.write(f"You can access Lucky Reactor via http://{ip_address}:7860")
|
71 |
+
info = get_server(credentials, instance_name)
|
72 |
+
st.write(info)
|
73 |
with st.form("deactivate_form"):
|
74 |
token = st.text_input("Token")
|
75 |
submitted = st.form_submit_button("Terminate 🕊️")
|