Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 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)
|
|
@@ -17,21 +16,11 @@ def test_file_upload(input_file):
|
|
| 17 |
return "❌ No file uploaded"
|
| 18 |
|
| 19 |
try:
|
| 20 |
-
#
|
| 21 |
-
file_path =
|
| 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)]
|
|
@@ -55,12 +44,13 @@ def test_file_upload(input_file):
|
|
| 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="
|
| 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 |
|
|
|
|
| 64 |
if __name__ == "__main__":
|
| 65 |
print("="*60)
|
| 66 |
print("Starting minimal Gradio test...")
|
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
Minimal Gradio Test - Just read and display OBJ file
|
| 3 |
"""
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
|
| 7 |
def test_file_upload(input_file):
|
| 8 |
"""Simple function to test if file upload works"""
|
| 9 |
print("\n" + "="*60)
|
|
|
|
| 16 |
return "❌ No file uploaded"
|
| 17 |
|
| 18 |
try:
|
| 19 |
+
# With type="filepath", input_file is a string path
|
| 20 |
+
file_path = input_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
print(f"File path: {file_path}")
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
# Read first 10 lines
|
| 25 |
with open(file_path, 'r') as f:
|
| 26 |
lines = [f.readline() for _ in range(10)]
|
|
|
|
| 44 |
# Create simple interface
|
| 45 |
demo = gr.Interface(
|
| 46 |
fn=test_file_upload,
|
| 47 |
+
inputs=gr.File(label="Upload OBJ File", file_types=[".obj"], type="filepath"), # Changed here
|
| 48 |
outputs=gr.Textbox(label="Result", lines=15),
|
| 49 |
title="🧪 File Upload Test",
|
| 50 |
description="Upload an OBJ file to test if Gradio file upload is working."
|
| 51 |
)
|
| 52 |
|
| 53 |
+
|
| 54 |
if __name__ == "__main__":
|
| 55 |
print("="*60)
|
| 56 |
print("Starting minimal Gradio test...")
|