def login(): try: if flask.request.method == 'POST': data = flask.request.get_json() email = data["email"].replace("\'","").replace("\"","") password = data["password"].replace("\'","").replace("\"","") retVal = DBHelper.checkCredential(email,password) # if email and password true if retVal == Constants.SUCCESS: user = User(email) flask_login.login_user(user) print("login success") return flask.jsonify({"status":Constants.SUCCESS}) elif retVal == Constants.ERROR_WRONG_EMAIL_PASS: # invalid credentials return flask.jsonify({"status":Constants.ERROR_WRONG_EMAIL_PASS}) else: # unknwon server error return flask.jsonify({"status":Constants.ERROR_UNKNOWN}) except Exception as e: print("Exception:",str(e)) return flask.render_template('login.html')