1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 13:04:19 +00:00
pds-2021-g2-nest/code/backend/nest_backend/__main__.py
2021-05-12 18:06:59 +02:00

24 lines
745 B
Python

"""
This is the runner for the server.
"""
import os
import sys
from .gestione import *
from .app import app, extension_sqlalchemy
from .database import User
print(" * Swagger docs will be available at http://127.0.0.1:5000/docs")
with app.app_context():
print(" * Creating database tables...")
extension_sqlalchemy.create_all(app=app)
if not User.query.filter_by(isAdmin=True).all():
print(" * Creating default admin account...")
extension_sqlalchemy.session.add(
User(email="admin@admin.com", password=gen_password("password"), username="admin", isAdmin=True))
extension_sqlalchemy.session.commit()
print(" * Created! Username: admin | Password: password")
app.run(debug=__debug__)