Wauplin HF staff commited on
Commit
eca073c
1 Parent(s): 5e94338

Support non-app.py Spaces

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