Spaces:
Sleeping
Sleeping
| import sys | |
| import os.path as osp | |
| root_path = osp.abspath(osp.join(__file__, osp.pardir)) | |
| sys.path.append(root_path) | |
| from gradio_app import create_gradio_interface | |
| def main(): | |
| """Main function to launch the Gradio interface.""" | |
| try: | |
| demo = create_gradio_interface() | |
| # For Hugging Face Spaces deployment - always use share=True for safety | |
| import os | |
| print("π Launching PupilSense...") | |
| print(f"Environment variables: SPACE_ID={os.getenv('SPACE_ID')}, SYSTEM={os.getenv('SYSTEM')}") | |
| # Always use share=True for HF Spaces compatibility | |
| try: | |
| demo.launch( | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| share=True, | |
| show_error=True, | |
| quiet=False | |
| ) | |
| except Exception as launch_error: | |
| print(f"Launch failed with share=True, trying basic launch: {launch_error}") | |
| # Fallback to most basic launch | |
| demo.launch() | |
| except Exception as e: | |
| print(f"Error launching app: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| raise e | |
| if __name__ == "__main__": | |
| main() | |