from flask import Flask
app = Flask(__name__)
@app.route("/hello")
@app.route("/") # 注册路由
def hello():
"""
视图函数
:return: <h1>Hello,Flask!</h1>
"""
return "<h1>Hello,Flask!</h1>"
# 动态url
@app.route("/hi", defaults={"name": "JIM"})
@app.route("/hi/<name>")
def hi_name(name):
return "<h1>Hello,%s!</h1>" % name
if __name__ == "__main__":
app.run()