Spaces:
Sleeping
Sleeping
| """ | |
| Launcher script for SkillSprout | |
| Runs both the Gradio interface and MCP server | |
| """ | |
| import asyncio | |
| import subprocess | |
| import sys | |
| import time | |
| import threading | |
| from pathlib import Path | |
| def run_gradio_app(): | |
| """Run the main Gradio application""" | |
| print("π Starting Gradio App...") | |
| subprocess.run([sys.executable, "app.py"]) | |
| def run_mcp_server(): | |
| """Run the MCP server""" | |
| print("π Starting MCP Server...") | |
| subprocess.run([sys.executable, "mcp_server.py"]) | |
| def main(): | |
| """Main launcher function""" | |
| print("=" * 60) | |
| print("π± SKILLSPROUT") | |
| print(" AI-Powered Microlearning Platform") | |
| print("=" * 60) | |
| print() | |
| # Check if we're in the right directory | |
| if not Path("app.py").exists(): | |
| print("β Error: app.py not found. Please run this script from the project directory.") | |
| return | |
| print("Choose how to run the application:") | |
| print("1. Gradio App only (recommended for demo)") | |
| print("2. MCP Server only") | |
| print("3. Both Gradio App and MCP Server") | |
| print() | |
| choice = input("Enter your choice (1-3): ").strip() | |
| if choice == "1": | |
| print("\nπ― Starting Gradio App...") | |
| print("π± Interface will be available at: http://localhost:7860") | |
| run_gradio_app() | |
| elif choice == "2": | |
| print("\nπ Starting MCP Server...") | |
| print("π API will be available at: http://localhost:8000") | |
| print("π API docs at: http://localhost:8000/docs") | |
| run_mcp_server() | |
| elif choice == "3": | |
| print("\nπ Starting both services...") | |
| print("π± Gradio App: http://localhost:7860") | |
| print("π MCP Server: http://localhost:8000") | |
| print("π API docs: http://localhost:8000/docs") | |
| print() | |
| # Start MCP server in a separate thread | |
| mcp_thread = threading.Thread(target=run_mcp_server, daemon=True) | |
| mcp_thread.start() | |
| # Give MCP server time to start | |
| time.sleep(2) | |
| # Start Gradio app (this will block) | |
| run_gradio_app() | |
| else: | |
| print("β Invalid choice. Please run the script again.") | |
| if __name__ == "__main__": | |
| try: | |
| main() | |
| except KeyboardInterrupt: | |
| print("\n\nπ Goodbye! Thanks for using SkillSprout!") | |
| except Exception as e: | |
| print(f"\nβ Error: {e}") | |
| print("Please check your configuration and try again.") | |