julien-c HF staff Wauplin HF staff commited on
Commit
2b1fdf0
1 Parent(s): 9b19366

Support non-app.py Spaces (#2)

Browse files

- Support non-app.py Spaces (eca073c651b69b70b9401bac6df6c18765cb7ae6)


Co-authored-by: Lucain Pouget <Wauplin@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -24,10 +24,9 @@ def generate(spaces):
24
  ]
25
  print(space_ids)
26
  for space_id in space_ids:
27
- # TODO(support non-app.py Spaces)
28
- app_py = requests.get(
29
- url=f"https://huggingface.co/spaces/{space_id}/resolve/main/app.py"
30
- ).text
31
 
32
  input = PROMPT + f"```py{app_py}```"
33
 
 
24
  ]
25
  print(space_ids)
26
  for space_id in space_ids:
27
+ app_file = huggingface_hub.SpaceCard.load(space_id).data.get("app_file", "app.py")
28
+ with open(huggingface_hub.hf_hub_download(space_id, repo_type="space", filename=app_file)) as app_file_path:
29
+ app_py = app_file_path.read()
 
30
 
31
  input = PROMPT + f"```py{app_py}```"
32