Spaces:
Runtime error
Runtime error
Add minimal test demo
Browse files- test_minimal.py +28 -0
test_minimal.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Minimal test to verify Gradio works on Spaces
|
| 3 |
+
"""
|
| 4 |
+
import gradio as gr
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
# Check if we're on Spaces
|
| 8 |
+
IS_SPACES = (
|
| 9 |
+
os.getenv("SPACE_ID") is not None or
|
| 10 |
+
os.getenv("SYSTEM") == "spaces" or
|
| 11 |
+
os.getenv("HF_SPACE_ID") is not None
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
# Create a minimal demo
|
| 15 |
+
with gr.Blocks(title="Test Demo") as demo:
|
| 16 |
+
gr.Markdown("# Test Demo")
|
| 17 |
+
gr.Markdown("If you see this, Gradio is working!")
|
| 18 |
+
text_input = gr.Textbox(label="Test Input")
|
| 19 |
+
text_output = gr.Textbox(label="Test Output")
|
| 20 |
+
|
| 21 |
+
def echo(text):
|
| 22 |
+
return f"You said: {text}"
|
| 23 |
+
|
| 24 |
+
text_input.submit(echo, inputs=text_input, outputs=text_output)
|
| 25 |
+
|
| 26 |
+
print(f"Demo created: {type(demo)}")
|
| 27 |
+
print(f"IS_SPACES: {IS_SPACES}")
|
| 28 |
+
|