dev_LMS / run_app.py
raymondEDS
setup
9cc64fb
#!/usr/bin/env python3
"""
Dev LMS Startup Script
======================
This script provides an easy way to start the Dev LMS application.
It handles dependency checking and provides helpful information.
"""
import subprocess
import sys
import os
def check_dependencies():
"""Check if required dependencies are installed"""
required_packages = [
'streamlit',
'streamlit_authenticator',
'PyPDF2',
'yaml',
'bcrypt'
]
missing_packages = []
for package in required_packages:
try:
__import__(package.replace('-', '_'))
except ImportError:
missing_packages.append(package)
return missing_packages
def install_dependencies():
"""Install missing dependencies"""
print("Installing missing dependencies...")
try:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
print("βœ… Dependencies installed successfully!")
return True
except subprocess.CalledProcessError:
print("❌ Failed to install dependencies. Please install them manually:")
print(" pip install -r requirements.txt")
return False
def main():
print("πŸš€ Dev LMS - Learning Management System")
print("=" * 50)
# Check if we're in the right directory
if not os.path.exists('src/streamlit_app.py'):
print("❌ Error: Please run this script from the project root directory")
print(" (where src/streamlit_app.py is located)")
sys.exit(1)
# Check dependencies
print("πŸ” Checking dependencies...")
missing = check_dependencies()
if missing:
print(f"❌ Missing dependencies: {', '.join(missing)}")
response = input("Would you like to install them now? (y/n): ")
if response.lower() in ['y', 'yes']:
if not install_dependencies():
sys.exit(1)
else:
print("Please install dependencies manually and try again.")
sys.exit(1)
else:
print("βœ… All dependencies are installed!")
print("\n🎯 Starting Dev LMS...")
print("πŸ“– Default login credentials:")
print(" - Admin: admin / admin123")
print(" - Teacher: teacher / teacher123")
print(" - Student: student / student123")
print("\n🌐 The application will open in your browser at: http://localhost:8501")
print("⏹️ Press Ctrl+C to stop the application")
print("=" * 50)
try:
# Start the Streamlit app
subprocess.run([
sys.executable, '-m', 'streamlit', 'run',
'src/streamlit_app.py',
'--server.port=8501',
'--server.headless=true'
])
except KeyboardInterrupt:
print("\nπŸ‘‹ Dev LMS stopped. Goodbye!")
except Exception as e:
print(f"❌ Error starting application: {e}")
sys.exit(1)
if __name__ == "__main__":
main()