Пример #1
0
def create_category():
    """ Create new category. """
    if request.is_json:
        data = request.get_json()
        categ = Category(data["name"])
        saved_category = categ.create()
        response = {"category": saved_category.to_dict()}
        return make_response(jsonify(response), 201)
    abort(404)
Пример #2
0
 def create_new_category(self, name):
     """ Helo method to create new category. """
     category = Category(name)
     category.create()
     return category