File size: 1,840 Bytes
94ecb74 4d85aba 94ecb74 |
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 66 67 68 69 |
#!/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() |