from app import create_app, db from app.models import User, Incident app = create_app() @app.cli.command() def init_db(): """Initialize the database with tables""" db.create_all() print("Database tables created successfully!") @app.cli.command() def create_test_user(): """Create a test user for development""" email = "test@example.com" password = "test123" # Check if user already exists if User.query.filter_by(email=email).first(): print(f"User {email} already exists!") return user = User(email=email) user.set_password(password) db.session.add(user) db.session.commit() print(f"Test user created: {email} / {password}") if __name__ == '__main__': with app.app_context(): db.create_all() print("Database initialized!") app.run(debug=True, host='0.0.0.0', port=5000)