2021-04-21 16:47:18 +00:00
|
|
|
"""
|
|
|
|
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-12 16:06:59 +00:00
|
|
|
from .database import User
|
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-04-28 22:07:43 +00:00
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
app.run(debug=__debug__)
|