""" 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 )