university-final-iot-backend/app/mod_accounts/controllers.py

17 lines
493 B
Python
Raw Normal View History

2018-05-03 14:40:30 +00:00
import json
from app import db
from flask import request, current_app
from .models import Account, Role
def initialize_routes(accounts):
@accounts.route("/", methods=['POST'])
def create():
json_body = json.loads(request.data)
with current_app.app_context():
acct = Account(2, json_body["user.username"],
json_body["user.password"])
db.session.add(acct)
db.session.commit()
return "Success!"