-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (31 loc) · 855 Bytes
/
main.py
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
34
35
36
37
38
39
40
# flask_sqlalchemy/app.py
from flask import Flask
from flask.globals import request
from flask.templating import render_template
from flask_graphql import GraphQLView
from models import db_session
from schema import schema, Users
app = Flask(__name__)
app.debug = True
app.add_url_rule(
'/graphql',
view_func=GraphQLView.as_view(
'graphql',
schema=schema,
graphiql=True # for having the GraphiQL interface
)
)
@app.route('/adduser', methods=['POST', 'GET'])
def add_user():
if request.method == 'POST':
data = request.get_json()
return 'all goog'
elif request.method == 'GET':
return render_template('adduser.html', **{})
else:
return 400
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
if __name__ == '__main__':
app.run()