|
|
""" |
|
|
Minimal Gradio Test - Just read and display OBJ file |
|
|
""" |
|
|
import gradio as gr |
|
|
|
|
|
|
|
|
def test_file_upload(input_file): |
|
|
"""Simple function to test if file upload works""" |
|
|
print("\n" + "="*60) |
|
|
print("π TEST FUNCTION CALLED!") |
|
|
print(f"Type: {type(input_file)}") |
|
|
print(f"Value: {input_file}") |
|
|
print("="*60 + "\n") |
|
|
|
|
|
if input_file is None: |
|
|
return "β No file uploaded" |
|
|
|
|
|
try: |
|
|
|
|
|
file_path = input_file |
|
|
|
|
|
print(f"File path: {file_path}") |
|
|
|
|
|
|
|
|
with open(file_path, 'r') as f: |
|
|
lines = [f.readline() for _ in range(10)] |
|
|
|
|
|
result = "β
File uploaded successfully!\n\n" |
|
|
result += f"File path: {file_path}\n\n" |
|
|
result += "First 10 lines:\n" |
|
|
result += "="*50 + "\n" |
|
|
result += "".join(lines) |
|
|
result += "="*50 |
|
|
|
|
|
print("SUCCESS! Returning result") |
|
|
return result |
|
|
|
|
|
except Exception as e: |
|
|
error_msg = f"β Error: {str(e)}" |
|
|
print(error_msg) |
|
|
return error_msg |
|
|
|
|
|
|
|
|
|
|
|
demo = gr.Interface( |
|
|
fn=test_file_upload, |
|
|
inputs=gr.File(label="Upload OBJ File", file_types=[".obj"], type="filepath"), |
|
|
outputs=gr.Textbox(label="Result", lines=15), |
|
|
title="π§ͺ File Upload Test", |
|
|
description="Upload an OBJ file to test if Gradio file upload is working." |
|
|
) |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
print("="*60) |
|
|
print("Starting minimal Gradio test...") |
|
|
print("="*60) |
|
|
|
|
|
demo.launch( |
|
|
server_name="0.0.0.0", |
|
|
server_port=7860, |
|
|
share=False, |
|
|
show_error=True |
|
|
) |
|
|
|