arahrooh commited on
Commit
b277db8
·
1 Parent(s): be365de

Fix: Use simplest possible Gradio Interface instead of Blocks

Browse files
Files changed (1) hide show
  1. test_minimal.py +8 -32
test_minimal.py CHANGED
@@ -1,42 +1,18 @@
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 - CRITICAL: demo must be at module level
15
- with gr.Blocks(title="Test Demo") as demo:
16
- gr.Markdown("# ✅ Test Demo - Gradio is Working!")
17
- gr.Markdown("If you see this message, Gradio is working correctly on Spaces!")
18
-
19
- text_input = gr.Textbox(label="Test Input", placeholder="Type something here...")
20
- text_output = gr.Textbox(label="Test Output", interactive=False)
21
-
22
- def echo(text):
23
- if not text:
24
- return "Please enter some text"
25
- return f"You said: {text}"
26
-
27
- text_input.submit(echo, inputs=text_input, outputs=text_output)
28
-
29
- # CRITICAL: Ensure demo is accessible
30
  print(f"Demo created: {type(demo)}")
31
- print(f"IS_SPACES: {IS_SPACES}")
32
  print(f"Demo is valid: {isinstance(demo, (gr.Blocks, gr.Interface))}")
33
 
34
- # Don't use assertions - they might cause issues on Spaces
35
- # Just ensure demo is set
36
- if demo is None:
37
- print("ERROR: Demo is None!")
38
- elif not isinstance(demo, (gr.Blocks, gr.Interface)):
39
- print(f"ERROR: Demo is invalid type: {type(demo)}")
40
- else:
41
- print("✅ Demo is ready")
42
-
 
1
  """
2
  Minimal test to verify Gradio works on Spaces
3
+ This is the absolute simplest Gradio app possible
4
  """
5
  import gradio as gr
 
6
 
7
+ # Create the simplest possible demo
8
+ demo = gr.Interface(
9
+ fn=lambda x: f"You said: {x}",
10
+ inputs="text",
11
+ outputs="text",
12
+ title="Test Demo",
13
+ description="If you see this, Gradio is working!"
14
  )
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  print(f"Demo created: {type(demo)}")
 
17
  print(f"Demo is valid: {isinstance(demo, (gr.Blocks, gr.Interface))}")
18