-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (26 loc) · 731 Bytes
/
app.py
File metadata and controls
33 lines (26 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Imports
from flask import Flask
from flask_graphql import GraphQLView
from flask_cors import CORS
from flask_json import FlaskJSON
from config import config
from helpers.database import db_session
from schema import schema
def create_app(config_name):
app = Flask(__name__)
CORS(app)
FlaskJSON(app)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
app.add_url_rule(
'/graphql',
view_func=GraphQLView.as_view(
'graphql',
schema=schema,
graphiql=True # for having the GraphiQL interface
)
)
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
return app