-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
37 lines (32 loc) · 1.23 KB
/
run.py
File metadata and controls
37 lines (32 loc) · 1.23 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
from app import create_app, socketio
from app.extensions import db
from app.models import User
from werkzeug.security import generate_password_hash
app = create_app()
def create_initial_admin():
with app.app_context():
db.create_all()
if not User.query.filter_by(is_admin=True).first():
# Change credentials as needed!
first_name = 'Admin'
last_name = 'User'
email = 'admin@example.com'
password = 'admin123'
if not User.query.filter_by(email=email).first():
admin = User(
first_name=first_name,
last_name=last_name,
email=email,
password=generate_password_hash(password),
is_admin=True
)
db.session.add(admin)
db.session.commit()
print(f'Admin user created: {email} / {password}')
else:
print('Admin email already exists, skipping admin creation.')
else:
print('Admin user already exists.')
if __name__ == '__main__':
create_initial_admin()
socketio.run(app, host='0.0.0.0', port=app.config.get('PORT', 5000))