Update app.py
Browse files
app.py
CHANGED
|
@@ -47,6 +47,26 @@ def show_s(name,d_app,token):
|
|
| 47 |
#print(f"{line2}")
|
| 48 |
return(gr.update(label="Spaces", choices=[s for s in spaces]),gr.update(label="Spaces", choices=[s for s in spaces]))
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
def show_f(repo,name,token):
|
| 51 |
api = HfApi(token=token)
|
| 52 |
f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="space"))
|
|
@@ -201,7 +221,7 @@ with gr.Blocks() as build:
|
|
| 201 |
f_btn.click(get_f,[r_name,ss_name,token],[a_files,z_files])
|
| 202 |
r_t.change(cyc,r_t,[m_t,files])
|
| 203 |
|
| 204 |
-
sd_btn.click(
|
| 205 |
sd_name.change(show_f,[rd_name,sd_name],dd_app)
|
| 206 |
ld_btn.click(load_space_d,[rd_name,sd_name,dd_app],[rd_t])
|
| 207 |
|
|
|
|
| 47 |
#print(f"{line2}")
|
| 48 |
return(gr.update(label="Spaces", choices=[s for s in spaces]),gr.update(label="Spaces", choices=[s for s in spaces]))
|
| 49 |
|
| 50 |
+
def show_s_d(name,d_app,token):
|
| 51 |
+
api = HfApi(token=token)
|
| 52 |
+
author=name
|
| 53 |
+
s_ist = (api.list_spaces(author=author))
|
| 54 |
+
print (s_ist)
|
| 55 |
+
file_j = open(f'{uid}/tmp_j','w')
|
| 56 |
+
file_j.writelines(str(s_ist))
|
| 57 |
+
file_j.close()
|
| 58 |
+
file_b = open(f'{uid}/tmp_j','r')
|
| 59 |
+
r_file = file_b.readlines()
|
| 60 |
+
spaces=[]
|
| 61 |
+
spaces2=[]
|
| 62 |
+
for line in r_file:
|
| 63 |
+
if "'id':" in line:
|
| 64 |
+
line = line.split(":",1)[1]
|
| 65 |
+
line = line.split("/",1)[1]
|
| 66 |
+
line2 = line.replace("'","").replace(",","").replace("\n","")
|
| 67 |
+
spaces.append(line2)
|
| 68 |
+
#print(f"{line2}")
|
| 69 |
+
return(gr.update(label="Spaces", choices=[s for s in spaces]))
|
| 70 |
def show_f(repo,name,token):
|
| 71 |
api = HfApi(token=token)
|
| 72 |
f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="space"))
|
|
|
|
| 221 |
f_btn.click(get_f,[r_name,ss_name,token],[a_files,z_files])
|
| 222 |
r_t.change(cyc,r_t,[m_t,files])
|
| 223 |
|
| 224 |
+
sd_btn.click(show_s_d,rd_name,[sd_name])
|
| 225 |
sd_name.change(show_f,[rd_name,sd_name],dd_app)
|
| 226 |
ld_btn.click(load_space_d,[rd_name,sd_name,dd_app],[rd_t])
|
| 227 |
|