Spaces:
Runtime error
Runtime error
elfsong
commited on
Commit
β’
a1561e0
1
Parent(s):
bd3bfcd
Update
Browse files
app.py
CHANGED
@@ -1,8 +1,22 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
def activate_server():
|
8 |
return True
|
@@ -10,7 +24,8 @@ def activate_server():
|
|
10 |
|
11 |
st.title("Lucky Reactor")
|
12 |
|
13 |
-
|
|
|
14 |
|
15 |
st.image("cover.jpg", caption="Reactor is currently " + "running π" if status else "sleeping π΄" + ".")
|
16 |
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
3 |
+
import googleapiclient.discovery
|
4 |
+
from google.oauth2 import service_account
|
5 |
+
|
6 |
+
def auth():
|
7 |
+
with open("/tmp/token.json", "w") as token_f:
|
8 |
+
token_f.write("Hello")
|
9 |
+
return credentials
|
10 |
+
|
11 |
+
def get_status(credentials):
|
12 |
+
status = False
|
13 |
+
client = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
14 |
+
|
15 |
+
result = client.instances().list(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c').execute()
|
16 |
+
for item in result['items']:
|
17 |
+
if item["name"] == "oj":
|
18 |
+
status = True if item["status"] == "RUNNING" else False
|
19 |
+
return status
|
20 |
|
21 |
def activate_server():
|
22 |
return True
|
|
|
24 |
|
25 |
st.title("Lucky Reactor")
|
26 |
|
27 |
+
credentials = auth()
|
28 |
+
|
29 |
|
30 |
st.image("cover.jpg", caption="Reactor is currently " + "running π" if status else "sleeping π΄" + ".")
|
31 |
|