xp3857 commited on
Commit
c096185
·
1 Parent(s): aa0384c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import sys
3
  import uuid
4
  import gradio as gr
 
5
  from pathlib import Path
6
  from huggingface_hub import (create_repo,get_full_repo_name,upload_file,CommitOperationAdd,HfApi)
7
  uid = uuid.uuid4()
@@ -50,12 +51,18 @@ def build_space(token,t_name,s_type,m_type=None,r_type=None,d_app=None,d_css=Non
50
  pass
51
  api = HfApi(token=token)
52
  repo_name = get_full_repo_name(model_id=model_id, token=token)
 
53
 
54
 
55
  try:
56
  api_url = f'https://huggingface.co/api/spaces/{model_id}'
57
  if s_type == "A":
58
- with open(f'https://huggingface.co/spaces/{model_id}/raw/main/{d_app}', "r") as f:
 
 
 
 
 
59
  app = f.read()
60
  app = app.replace("gr.Blocks", "edited")
61
  #app = app.replace("$app2", d_app)
 
2
  import sys
3
  import uuid
4
  import gradio as gr
5
+ import requests
6
  from pathlib import Path
7
  from huggingface_hub import (create_repo,get_full_repo_name,upload_file,CommitOperationAdd,HfApi)
8
  uid = uuid.uuid4()
 
51
  pass
52
  api = HfApi(token=token)
53
  repo_name = get_full_repo_name(model_id=model_id, token=token)
54
+ print (repo_name)
55
 
56
 
57
  try:
58
  api_url = f'https://huggingface.co/api/spaces/{model_id}'
59
  if s_type == "A":
60
+ r = requests.get(f'https://huggingface.co/spaces/{model_id}/raw/main/{d_app}')
61
+ file = open(f'tmp_file{uid}.txt','w')
62
+ file.writelines(r.text)
63
+ file.close()
64
+
65
+ with open(f'tmp_file{uid}.txt', "r") as f:
66
  app = f.read()
67
  app = app.replace("gr.Blocks", "edited")
68
  #app = app.replace("$app2", d_app)