1TSnakers commited on
Commit
e3bca2d
·
verified ·
1 Parent(s): 8441976

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -3,13 +3,17 @@ import requests
3
 
4
  HOST = "https://1tsnakers-ollamasearchapi.hf.space"
5
 
6
- if st.button("make list"):
 
7
  r = requests.get(f"{HOST}/ping")
 
 
8
 
9
- if r.status_code != 200:
 
10
  st.error(f"HTTP error {r.status_code}")
 
 
11
 
12
- r = requests.get(f"{HOST}/library")
13
-
14
- st.write(r.json())
15
 
 
3
 
4
  HOST = "https://1tsnakers-ollamasearchapi.hf.space"
5
 
6
+ def is_api_up():
7
+
8
  r = requests.get(f"{HOST}/ping")
9
+
10
+ return r.status_code == 200:
11
 
12
+ if st.button("make list"):
13
+ if !is_api_up():
14
  st.error(f"HTTP error {r.status_code}")
15
+ else:
16
+ r = requests.get(f"{HOST}/library")
17
 
18
+ st.write(r.json())
 
 
19