forked from jesienazareth/jesync_dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed_users.py
More file actions
22 lines (16 loc) · 731 Bytes
/
Copy pathseed_users.py
File metadata and controls
22 lines (16 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import Flask
from db import db, UserModel
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
with app.app_context():
db.create_all()
if not UserModel.query.filter_by(username="admin").first():
db.session.add(UserModel(username="admin", password="adminpass", role="admin"))
print("✅ Created admin user.")
if not UserModel.query.filter_by(username="viewer").first():
db.session.add(UserModel(username="viewer", password="viewerpass", role="viewer"))
print("✅ Created viewer user.")
db.session.commit()
print("🎉 Done seeding users.")