Change response to JSON

master
esensar 2018-05-03 17:01:32 +02:00
parent 2f9fac3540
commit 23303bdb3f
1 changed files with 13 additions and 10 deletions

View File

@ -1,17 +1,20 @@
from app import db from app import db
from flask import request, current_app from flask import request, jsonify, abort
from .models import Account, Role from .models import Account, Role
def initialize_routes(accounts): def initialize_routes(accounts):
@accounts.route("/", methods=['POST']) @accounts.route("/", methods=['POST'])
def create(): def create():
with current_app.app_context(): print(request.data)
print(request.data) user = request.data.get('user')
user = request.data.get('user') acct = Account(user.get('username'),
acct = Account(user.get('username'), user.get('password'),
user.get('password'), user.get('email'),
user.get('email'), 2)
2) acct.save()
acct.save() response = jsonify({
return "Success!" 'message':'Success!'
})
response.status_code = 200
return response