Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Simplified ID Agents App for Troubleshooting | |
| This version isolates potential import issues and provides basic functionality | |
| """ | |
| import gradio as gr | |
| import json | |
| import os | |
| # Simple authentication test | |
| def create_simple_app(): | |
| """Create a simplified version of the ID Agents app""" | |
| with gr.Blocks(title="ID Agents - Test Version") as app: | |
| # Custom CSS (minimal) | |
| app.css = """ | |
| .main-container { | |
| max-width: 1200px; | |
| margin: 0 auto; | |
| padding: 20px; | |
| } | |
| """ | |
| # Header | |
| gr.Markdown("# π¦ ID Agents - Test Version") | |
| gr.Markdown("This is a simplified version to test basic functionality and authentication.") | |
| # Simple chat interface | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| gr.Markdown("### Quick Test Panel") | |
| test_input = gr.Textbox(label="Test Input", placeholder="Type a message...") | |
| test_btn = gr.Button("Send Test") | |
| with gr.Column(scale=2): | |
| gr.Markdown("### Chat Test") | |
| chatbot = gr.Chatbot(label="Test Chat") | |
| # Simple function | |
| def test_response(message): | |
| if not message.strip(): | |
| return [["", "Please enter a message to test."]] | |
| response = f"β Test successful! You said: '{message}'" | |
| return [["Test User", message], ["ID Agents Test", response]] | |
| # Connect the function | |
| test_btn.click( | |
| test_response, | |
| inputs=[test_input], | |
| outputs=[chatbot] | |
| ) | |
| # Footer | |
| gr.Markdown("---") | |
| gr.Markdown("π§ͺ **Test Status**: If you can see this interface and interact with it, the basic setup is working!") | |
| return app | |
| def main(): | |
| """Main function with authentication""" | |
| print("π§ͺ Starting ID Agents Test Version...") | |
| # Create the app | |
| try: | |
| app = create_simple_app() | |
| print("β App created successfully") | |
| except Exception as e: | |
| print(f"β Failed to create app: {e}") | |
| return | |
| # Authentication credentials (simplified) | |
| auth_credentials = [ | |
| ("test", "test123"), | |
| ("admin", "admin123"), | |
| ("dr_smith", "idweek2025"), | |
| ("guest", "guest123") | |
| ] | |
| auth_message = """ | |
| π§ͺ **ID Agents Test Version** | |
| Test credentials: | |
| β’ test / test123 | |
| β’ admin / admin123 | |
| β’ dr_smith / idweek2025 | |
| β’ guest / guest123 | |
| """ | |
| # Launch configuration | |
| launch_config = { | |
| "auth": auth_credentials, | |
| "auth_message": auth_message, | |
| "server_name": "0.0.0.0", | |
| "server_port": 7860, | |
| "share": False, | |
| "show_error": True | |
| } | |
| print("π Authentication enabled") | |
| print("π Launching app...") | |
| try: | |
| app.launch(**launch_config) | |
| except Exception as e: | |
| print(f"β Failed to launch app: {e}") | |
| # Try without authentication as fallback | |
| print("π Trying without authentication...") | |
| try: | |
| app.launch( | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| share=False | |
| ) | |
| except Exception as e2: | |
| print(f"β Complete failure: {e2}") | |
| if __name__ == "__main__": | |
| main() | |