Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 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 |
-
#
|
| 16 |
-
repos = api.
|
| 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 |
-
#
|
| 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")
|