1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-30 08:24:20 +00:00
pds-2021-g2-nest/code/backend/nest_backend/__main__.py

24 lines
718 B
Python
Raw Normal View History

"""
This is the runner for the server.
"""
2021-05-07 17:46:14 +00:00
import os
import sys
2021-04-19 14:14:51 +00:00
2021-05-07 17:46:14 +00:00
from .gestione import *
from .app import app, extension_sqlalchemy
2021-05-05 20:21:04 +00:00
2021-05-07 17:46:14 +00:00
print(" * Swagger docs will be available at http://127.0.0.1:5000/docs")
2021-05-05 20:21:04 +00:00
2021-05-07 17:46:14 +00:00
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")
2021-05-07 17:46:14 +00:00
app.run(debug=__debug__)