Flask-Files/init_db.py
2025-03-22 12:30:45 +01:00

18 lines
No EOL
524 B
Python

from app import create_app, db
from app.models import User, File, Share, Download
app = create_app()
with app.app_context():
# Create all tables
db.create_all()
# Check if we need to create an admin user
if not User.query.filter_by(username='admin').first():
admin = User(username='admin')
admin.set_password('password') # Change this in production!
db.session.add(admin)
db.session.commit()
print('Admin user created!')
print('Database initialized!')