ckc99u commited on
Commit
2addbd2
Β·
verified Β·
1 Parent(s): d72cef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -45
app.py CHANGED
@@ -2,60 +2,34 @@
2
  import sys
3
  import gradio as gr
4
 
5
- def test_file_upload(input_file):
6
- """Simple function to test if file upload works"""
7
- print("\n" + "="*60, flush=True)
8
- print("πŸ” TEST FUNCTION CALLED!", flush=True)
9
- print(f"Type: {type(input_file)}", flush=True)
10
- print(f"Value: {input_file}", flush=True)
11
- print("="*60 + "\n", flush=True)
12
 
13
- if input_file is None:
14
- return "❌ No file uploaded"
15
 
16
- try:
17
- file_path = input_file if isinstance(input_file, str) else str(input_file)
18
- print(f"File path: {file_path}", flush=True)
19
-
20
- # Manual file type validation (workaround for file_types bug)
21
- if not file_path.lower().endswith('.obj'):
22
- return f"❌ Invalid file type. Please upload a .obj file. Got: {file_path}"
23
-
24
- with open(file_path, 'r') as f:
25
- lines = [f.readline() for _ in range(10)]
26
-
27
- result = "βœ… File uploaded successfully!\n\n"
28
- result += f"File path: {file_path}\n\n"
29
- result += "First 10 lines:\n" + "="*50 + "\n"
30
- result += "".join(lines) + "="*50
31
-
32
- print("SUCCESS! Returning result", flush=True)
33
- return result
34
-
35
- except Exception as e:
36
- error_msg = f"❌ Error: {str(e)}"
37
- print(error_msg, flush=True)
38
- import traceback
39
- traceback.print_exc()
40
- return error_msg
41
 
42
- # FIX: Remove file_types parameter to avoid JSON schema bug
43
  demo = gr.Interface(
44
- fn=test_file_upload,
45
- inputs=gr.File(label="Upload OBJ File (remove file_types to fix bug)", type="filepath"),
46
- outputs=gr.Textbox(label="Result", lines=15),
47
- title="πŸ§ͺ File Upload Test",
48
- description="Upload an OBJ file to test. File type validation is done in code."
49
  )
50
 
51
  if __name__ == "__main__":
52
- print("="*60, flush=True)
53
- print("πŸš€ Starting Gradio app...", flush=True)
54
- print("="*60, flush=True)
55
 
56
  demo.launch(
57
  server_name="0.0.0.0",
58
  server_port=7860,
59
  share=False,
60
- show_error=True
61
- )
 
 
2
  import sys
3
  import gradio as gr
4
 
5
+ def echo_text(text):
6
+ """Simple echo function for debugging"""
7
+ sys.stdout.flush() # Force flush
8
+ print(f"[DEBUG] Function called with: {text}", flush=True)
 
 
 
9
 
10
+ if not text:
11
+ return "⚠️ No text provided"
12
 
13
+ return f"βœ… Echo: {text}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ # Minimal interface
16
  demo = gr.Interface(
17
+ fn=echo_text,
18
+ inputs=gr.Textbox(label="Input Text", placeholder="Type something..."),
19
+ outputs=gr.Textbox(label="Output"),
20
+ title="πŸ§ͺ Text Echo Test",
21
+ description="Simple echo test to verify Gradio is working"
22
  )
23
 
24
  if __name__ == "__main__":
25
+ print("=" * 60, flush=True)
26
+ print("πŸš€ Starting text echo test...", flush=True)
27
+ print("=" * 60, flush=True)
28
 
29
  demo.launch(
30
  server_name="0.0.0.0",
31
  server_port=7860,
32
  share=False,
33
+ show_error=True,
34
+ debug=True # Enable debug mode
35
+ )