ambujm22 commited on
Commit
30c0cfe
·
verified ·
1 Parent(s): ed317eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -4,7 +4,7 @@ os.environ.setdefault("GRADIO_USE_CDN", "true")
4
 
5
  import gradio as gr
6
 
7
- # (Optional) ZeroGPU probe — harmless on CPU. Will work once you switch HW to ZeroGPU.
8
  try:
9
  import spaces
10
  @spaces.GPU(duration=10)
@@ -13,11 +13,21 @@ try:
13
  except Exception:
14
  pass
15
 
16
- with gr.Blocks(title="Hello Space") as demo:
 
 
 
 
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(lambda s: f"echo: {s}", inp, out)
 
 
 
 
 
21
 
22
- # IMPORTANT: expose a top-level `demo`, and DO NOT call .launch()
23
- demo = demo.queue(max_size=8)
 
 
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)