def register(self, author_name=None, password=None, confirm=None, submit=None): if cherrypy.request.method.lower() != "post": return {} if author_name is None or password is None: return {"message": "You must specify both author name and password."} elif db.get_author(author_name) is not None: return {"message":"That author already exists."} elif password != confirm: return {"message":"Passwords did not match."} db.add_author(author_name, password) login_author(author_name,password) raise cherrypy.HTTPRedirect("/")
def api_add_author(): if not flask.request.is_json: return flask.jsonify({"msg": "Missing JSON in request"}), 400 return add_author(flask.request.get_json())