示例#1
0
 def create_ingredient(jwt):
     try:
         data = request.get_json()
         ingredient = Ingredient(**data)
         ingredient.insert()
         return jsonify({'success': True, 'result': ingredient.format()})
     except TypeError:
         abort(400)
示例#2
0
    def post_ingredient(jwt):
        res = request.get_json()
        if not res:
            abort(404)

        ingredient = Ingredient(**res)
        ingredient.insert()
        result = {"success": True, "result": ingredient.format()}
        return jsonify(result)