Newer
Older
from flask_security import Security, login_required
from flask_graphql import GraphQLView
from os import environ
from database.database import db_session, init_db, get_user_datastore
app = Flask(__name__)
app.debug = True if "DEBUG" in environ and environ["DEBUG"] else False
app.config["SECRET_KEY"] = "_" if "SECRET_KEY" not in environ else environ["SECRET_KEY"]
app.config["SECURITY_PASSWORD_SALT"] = app.config["SECRET_KEY"]
user_datastore = get_user_datastore()
security = Security(app, user_datastore)
app.add_url_rule(
'/graphql',
view_func=GraphQLView.as_view(
'graphql',
schema=schema,
graphiql=app.debug # for having the GraphiQL interface
)
)
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
@app.before_first_request
def initialize_database():
init_db()
if __name__ == '__main__':