batman
This commit is contained in:
commit
acb3c7642a
23 changed files with 3940 additions and 0 deletions
18
init_db.py
Normal file
18
init_db.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
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!')
|
Loading…
Add table
Add a link
Reference in a new issue