#提高代码复用性
def a():
def b():
print("A")
return b
@a
def c():
print("bbbb")
if __name__ == ‘__main__‘:
c = a()
c()
#对象形式# app.config.from_object(Config)
#文件形式app.config.from_pyfile("confuf.ini")
#环境变量host="自己电脑的本地地址",debug=True,port=8000
#跳转页面
from flask import Flask,request,redirect,render_template,jsonify
import json
class Config:
DEBUG = True
app = Flask(__name__)
# app.config.from_object(Config)
# app.config.from_pyfile("config.ini")
# app.config.from_envvar("")
@app.route("/")
def index():
# print(request.method)
# return render_template("index.html")
# return redirect(url_for("/login"))
# return redirect("/login")
res_dist = {
"name":"laowang",
"age": "18"
}
#吧字典变成字符串
res_st = json.dumps(res)
return jsonify(res)
@app.route("/login/")
def login():
return "aaaaa"
if __name__==‘__main__‘:
app.run()
原文:https://www.cnblogs.com/muzi98/p/14592923.html