Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,72 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
"""Simple
|
| 7 |
-
|
| 8 |
-
print(
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
if
|
| 11 |
-
return "
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 16 |
demo = gr.Interface(
|
| 17 |
-
fn=
|
| 18 |
-
inputs=gr.
|
| 19 |
-
outputs=gr.Textbox(label="
|
| 20 |
-
title="🧪
|
| 21 |
-
description="
|
| 22 |
-
)
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
-
print("="
|
| 26 |
-
print("
|
| 27 |
-
print("="
|
| 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 |
-
)
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Minimal Gradio Test - Just read and display OBJ file
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
+
def test_file_upload(input_file):
|
| 9 |
+
"""Simple function to test if file upload works"""
|
| 10 |
+
print("\n" + "="*60)
|
| 11 |
+
print("🔍 TEST FUNCTION CALLED!")
|
| 12 |
+
print(f"Type: {type(input_file)}")
|
| 13 |
+
print(f"Value: {input_file}")
|
| 14 |
+
print("="*60 + "\n")
|
| 15 |
|
| 16 |
+
if input_file is None:
|
| 17 |
+
return "❌ No file uploaded"
|
| 18 |
|
| 19 |
+
try:
|
| 20 |
+
# Try to get file path
|
| 21 |
+
file_path = None
|
| 22 |
+
|
| 23 |
+
if hasattr(input_file, 'name'):
|
| 24 |
+
file_path = input_file.name
|
| 25 |
+
elif isinstance(input_file, str):
|
| 26 |
+
file_path = input_file
|
| 27 |
+
elif isinstance(input_file, dict) and 'name' in input_file:
|
| 28 |
+
file_path = input_file['name']
|
| 29 |
+
|
| 30 |
+
print(f"File path: {file_path}")
|
| 31 |
+
|
| 32 |
+
if not file_path:
|
| 33 |
+
return f"❌ Could not get file path. Type was: {type(input_file)}"
|
| 34 |
+
|
| 35 |
+
# Read first 10 lines
|
| 36 |
+
with open(file_path, 'r') as f:
|
| 37 |
+
lines = [f.readline() for _ in range(10)]
|
| 38 |
+
|
| 39 |
+
result = "✅ File uploaded successfully!\n\n"
|
| 40 |
+
result += f"File path: {file_path}\n\n"
|
| 41 |
+
result += "First 10 lines:\n"
|
| 42 |
+
result += "="*50 + "\n"
|
| 43 |
+
result += "".join(lines)
|
| 44 |
+
result += "="*50
|
| 45 |
+
|
| 46 |
+
print("SUCCESS! Returning result")
|
| 47 |
+
return result
|
| 48 |
+
|
| 49 |
+
except Exception as e:
|
| 50 |
+
error_msg = f"❌ Error: {str(e)}"
|
| 51 |
+
print(error_msg)
|
| 52 |
+
return error_msg
|
| 53 |
+
|
| 54 |
|
| 55 |
+
# Create simple interface
|
| 56 |
demo = gr.Interface(
|
| 57 |
+
fn=test_file_upload,
|
| 58 |
+
inputs=gr.File(label="Upload OBJ File", file_types=[".obj"], type="file"),
|
| 59 |
+
outputs=gr.Textbox(label="Result", lines=15),
|
| 60 |
+
title="🧪 File Upload Test",
|
| 61 |
+
description="Upload an OBJ file to test if Gradio file upload is working.")
|
|
|
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|
| 64 |
+
print("="*60)
|
| 65 |
+
print("Starting minimal Gradio test...")
|
| 66 |
+
print("="*60)
|
| 67 |
|
| 68 |
demo.launch(
|
| 69 |
server_name="0.0.0.0",
|
| 70 |
server_port=7860,
|
| 71 |
share=False,
|
| 72 |
+
show_error=True)
|
|
|
|
|
|