File size: 840 Bytes
d87c106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from pathlib import Path
import gradio as gr

ROOT = Path("/work")

def list_repo():
    # Show a small tree of notebooks/scripts to confirm they are in the image
    exts = {".ipynb", ".py"}
    files = sorted([p.relative_to(ROOT) for p in ROOT.rglob("*") if p.suffix in exts])
    if not files:
        return "No .ipynb/.py files found under /work (did you COPY the repo into the image?)"
    return "\n".join(str(p) for p in files[:300])

with gr.Blocks(title="Split-Skip-and-Play") as demo:
    gr.Markdown("# Split-Skip-and-Play\nA lightweight UI (Gradio) running on Hugging Face Spaces.")
    out = gr.Textbox(label="Repo notebooks/scripts (first 300)", lines=20)
    gr.Button("Refresh file list").click(fn=list_repo, outputs=out)

demo.launch(
    server_name="0.0.0.0",
    server_port=int(os.getenv("PORT", "7860")),
)