final update
This commit is contained in:
18
app.py
18
app.py
@@ -622,6 +622,22 @@ def debug_content_positions(group_id):
|
||||
|
||||
return jsonify(content_data)
|
||||
|
||||
@app.cli.command("create-admin")
|
||||
@click.option("--username", default="admin", help="Admin username")
|
||||
@click.option("--password", help="Admin password")
|
||||
def create_admin(username, password):
|
||||
"""Create an admin user."""
|
||||
from models import User
|
||||
from extensions import bcrypt
|
||||
|
||||
hashed_password = bcrypt.generate_password_hash(password).decode('utf-8')
|
||||
user = User(username=username, password=hashed_password, role='admin')
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
print(f"Admin user '{username}' created successfully.")
|
||||
|
||||
|
||||
# Add this at the end of app.py
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user