File size: 1,715 Bytes
a5ba94d
6e2f01f
a5ba94d
 
2295ea6
cfb9027
6e2f01f
 
 
 
 
 
 
a5ba94d
6e2f01f
 
a5ba94d
2ce0171
cfb9027
 
2ce0171
6e2f01f
a5ba94d
6e2f01f
 
 
a5ba94d
6e2f01f
 
 
 
 
 
a5ba94d
6e2f01f
 
2ce0171
 
6e2f01f
a5ba94d
6e2f01f
058fe77
6e2f01f
 
 
 
39d160c
6e2f01f
 
 
 
058fe77
cfb9027
058fe77
6e2f01f
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
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:
        # With type="filepath", input_file is a string path
        file_path = input_file
        
        print(f"File path: {file_path}")
        
        # Read first 10 lines
        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


# Create simple interface
demo = gr.Interface(
    fn=test_file_upload,
    inputs=gr.File(label="Upload OBJ File", file_types=[".obj"], type="filepath"),  # Changed here
    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
    )