Spaces:
Running
Running
| #!/usr/bin/env python3 | |
| """ | |
| π Course Creator AI - Main Application Entry Point | |
| Launch the Gradio interface for course generation. | |
| Made with β€οΈ by Pink Pixel | |
| "Dream it, Pixel it" β¨ | |
| """ | |
| import os | |
| import sys | |
| import gradio as gr | |
| from pathlib import Path | |
| # Add the project root to Python path | |
| project_root = Path(__file__).parent | |
| sys.path.insert(0, str(project_root)) | |
| from coursecrafter.ui.gradio_app import create_coursecrafter_interface | |
| from coursecrafter.utils.config import config | |
| def setup_backend_credentials(): | |
| """Set up backend credentials for image generation""" | |
| # Set up Pollinations credentials for image generation | |
| if not os.getenv("POLLINATIONS_API_REFERENCE"): | |
| os.environ["POLLINATIONS_API_REFERENCE"] = "course-creator-ai-hf" | |
| print("π¨ Backend image generation credentials configured") | |
| def main(): | |
| """Main application entry point""" | |
| print("π Starting Course Creator AI...") | |
| # Set up backend credentials | |
| setup_backend_credentials() | |
| # Create and launch the Gradio interface | |
| try: | |
| interface = create_coursecrafter_interface() | |
| # Launch configuration | |
| launch_kwargs = { | |
| "server_name": "0.0.0.0", | |
| "server_port": 7860, | |
| "share": False, | |
| "show_error": True, | |
| "quiet": False | |
| } | |
| # Check if running in Hugging Face Spaces | |
| if os.getenv("SPACE_ID"): | |
| print("π Running in Hugging Face Spaces") | |
| launch_kwargs["share"] = True | |
| else: | |
| print("π₯οΈ Running locally") | |
| print("π Launching Course Creator AI interface...") | |
| interface.launch(**launch_kwargs) | |
| except Exception as e: | |
| print(f"β Failed to launch application: {e}") | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() |