-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·75 lines (63 loc) · 2.03 KB
/
run.py
File metadata and controls
executable file
·75 lines (63 loc) · 2.03 KB
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
70
71
72
73
74
#!/usr/bin/env python3
"""
Simple run script for SPMS
Handles database initialization and application startup
"""
import os
import sys
from app import app, db
from models import User, Project, Task, ActivityLog
from werkzeug.security import generate_password_hash
def init_database():
"""Initialize database with tables"""
print("🗄️ Initializing database...")
with app.app_context():
# Create all tables
db.create_all()
print("✅ Database tables created")
# Check if admin user exists
admin = User.query.filter_by(username='admin').first()
if not admin:
admin = User(
username='admin',
email='admin@spms.com',
password_hash=generate_password_hash('admin123'),
role='admin'
)
db.session.add(admin)
db.session.commit()
print("✅ Admin user created: admin / admin123")
else:
print("✅ Admin user already exists")
def run_application():
"""Run the Flask application"""
print("🚀 Starting SPMS...")
print("=" * 50)
print("📋 Application Information:")
print(" - URL: http://localhost:5000")
print(" - Admin: admin / admin123")
print(" - Database: SQLite")
print("=" * 50)
print("Press Ctrl+C to stop the server")
print()
try:
app.run(debug=True, host='0.0.0.0', port=5000)
except KeyboardInterrupt:
print("\n👋 Server stopped by user")
except Exception as e:
print(f"❌ Error starting server: {e}")
sys.exit(1)
def main():
"""Main function"""
print("🎯 Simple Project Management System (SPMS)")
print("=" * 50)
# Check if we're in the right directory
if not os.path.exists('app.py'):
print("❌ Error: app.py not found. Please run from the project directory.")
sys.exit(1)
# Initialize database
init_database()
# Run application
run_application()
if __name__ == '__main__':
main()