rahul7star commited on
Commit
e8b4e81
·
verified ·
1 Parent(s): d812319

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import HfApi, list_repo_files
3
+
4
+ # Initialize HF API
5
+ api = HfApi()
6
+
7
+ def list_repos_files(username: str):
8
+ """List all repos and files for a given Hugging Face username"""
9
+ output = ""
10
+ try:
11
+ repos = api.list_repos_objs(username=username)
12
+ if not repos:
13
+ return f"No repositories found for user '{username}'"
14
+
15
+ for repo in repos:
16
+ output += f"Repo: {repo.repo_id}\n"
17
+ try:
18
+ files = list_repo_files(repo_id=repo.repo_id)
19
+ if files:
20
+ for f in files:
21
+ output += f" - {f}\n"
22
+ else:
23
+ output += " (No files found)\n"
24
+ except Exception as e:
25
+ output += f" Failed to list files: {e}\n"
26
+ output += "\n"
27
+ except Exception as e:
28
+ return f"Error: {e}"
29
+
30
+ return output
31
+
32
+ # Build Gradio interface
33
+ with gr.Blocks() as demo:
34
+ gr.Markdown("## Hugging Face User Repository Scanner (ZeroGPU)")
35
+ username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star")
36
+ scan_button = gr.Button("Scan Repositories")
37
+ output_box = gr.Textbox(label="Repository Files", lines=25)
38
+
39
+ scan_button.click(list_repos_files, inputs=username_input, outputs=output_box)
40
+
41
+ demo.launch()