rahul7star commited on
Commit
394a74f
·
verified ·
1 Parent(s): acf354e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -1,19 +1,18 @@
1
- import gradio as gr
2
  import os
 
3
  from huggingface_hub import HfApi, list_repo_files
4
 
5
- # If you have a token for private repos, put it here; else None
6
- HF_TOKEN =os.getenv("HF_TOKEN")
7
 
8
  # Initialize HF API
9
  api = HfApi(token=HF_TOKEN)
10
 
11
  def list_repos_files(username: str):
12
- """List all repos and files for a given Hugging Face username"""
13
  output = ""
14
  try:
15
- # Use new method
16
- repos = api.list_repositories(repo_type="model", author=username)
17
  if not repos:
18
  return f"No repositories found for user '{username}'"
19
 
@@ -34,7 +33,7 @@ def list_repos_files(username: str):
34
 
35
  return output
36
 
37
- # Build Gradio interface
38
  with gr.Blocks() as demo:
39
  gr.Markdown("## Hugging Face User Repository Scanner (ZeroGPU)")
40
  username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star")
 
 
1
  import os
2
+ import gradio as gr
3
  from huggingface_hub import HfApi, list_repo_files
4
 
5
+ # Load HF token from environment variable
6
+ HF_TOKEN = os.getenv("HF_TOKEN")
7
 
8
  # Initialize HF API
9
  api = HfApi(token=HF_TOKEN)
10
 
11
  def list_repos_files(username: str):
 
12
  output = ""
13
  try:
14
+ # Get all models (repositories) for the user
15
+ repos = api.list_models(author=username, token=HF_TOKEN)
16
  if not repos:
17
  return f"No repositories found for user '{username}'"
18
 
 
33
 
34
  return output
35
 
36
+ # Gradio UI
37
  with gr.Blocks() as demo:
38
  gr.Markdown("## Hugging Face User Repository Scanner (ZeroGPU)")
39
  username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star")