# coding=utf-8
from flask import Flask, render_template, jsonify, request
app = Flask(__name__)
@app.route("/login", methods=['POST'])
def user_login():
username = request.values.get("username")
password = request.values.get("password")
if username and password:
if username == "root" and password == "123456":
return jsonify({"code": 1000, "msg": "恭喜,登录成功!"})
return jsonify({"code": 1001, "msg": "用户名或密码错误!!!"})
else:
return jsonify({"code": 1002, "msg": "用户名或密码不能为空!!!"})
@app.route('/')
def index():
return 'welcome'
if __name__ == '__main__':
app.run(debug=True)


