Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ os.environ.setdefault("GRADIO_USE_CDN", "true")
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
-
#
|
| 8 |
try:
|
| 9 |
import spaces
|
| 10 |
@spaces.GPU(duration=10)
|
|
@@ -13,11 +13,21 @@ try:
|
|
| 13 |
except Exception:
|
| 14 |
pass
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
gr.Markdown("### ✅ App is alive\nType to echo.")
|
| 18 |
inp = gr.Textbox(label="Input", value="hello")
|
| 19 |
out = gr.Textbox(label="Output")
|
| 20 |
-
inp.submit(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
|
|
|
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
# Optional: harmless on CPU; useful once you switch to ZeroGPU hardware
|
| 8 |
try:
|
| 9 |
import spaces
|
| 10 |
@spaces.GPU(duration=10)
|
|
|
|
| 13 |
except Exception:
|
| 14 |
pass
|
| 15 |
|
| 16 |
+
# Build a tiny UI
|
| 17 |
+
def echo(s: str) -> str:
|
| 18 |
+
return f"echo: {s}"
|
| 19 |
+
|
| 20 |
+
with gr.Blocks(title="Hello Space") as _demo:
|
| 21 |
gr.Markdown("### ✅ App is alive\nType to echo.")
|
| 22 |
inp = gr.Textbox(label="Input", value="hello")
|
| 23 |
out = gr.Textbox(label="Output")
|
| 24 |
+
inp.submit(echo, inp, out)
|
| 25 |
+
|
| 26 |
+
# Expose all common names that the Space supervisor might look for
|
| 27 |
+
demo = _demo.queue(max_size=8) # primary export
|
| 28 |
+
iface = demo # alias
|
| 29 |
+
app = demo # another alias
|
| 30 |
|
| 31 |
+
# For local debugging only (ignored on Spaces)
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|