Update app.py
Browse files
app.py
CHANGED
|
@@ -2,60 +2,34 @@
|
|
| 2 |
import sys
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
"""Simple function
|
| 7 |
-
|
| 8 |
-
print("
|
| 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
|
| 14 |
-
return "
|
| 15 |
|
| 16 |
-
|
| 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 |
-
#
|
| 43 |
demo = gr.Interface(
|
| 44 |
-
fn=
|
| 45 |
-
inputs=gr.
|
| 46 |
-
outputs=gr.Textbox(label="
|
| 47 |
-
title="π§ͺ
|
| 48 |
-
description="
|
| 49 |
)
|
| 50 |
|
| 51 |
if __name__ == "__main__":
|
| 52 |
-
print("="*60, flush=True)
|
| 53 |
-
print("π Starting
|
| 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 |
+
)
|