from flask import Blueprint, request, render_template, make_response, redirect, url_for
blue = Blueprint('first', '__name__')
# 带参数的render_template
@blue.route('/getfile/<name>/')
def getFile(name):
red = render_template("hello.html", name=name)
resp = make_response(red, 502)
print(resp)
return resp
# 带参数的render_template
@blue.route('/getredic/<name>/')
def getredic(name):
redic = redirect(url_for('first.getFile', name=name))
return redic
关于hello.html的HTML文档
<h2>{{ name }}好烦!想打联盟!</h2>
hello.html 存在于template中 也可以直接在示图函数直接创建 再按Alt+回车键 创建
要点一 : 重定向redirect(url_for('路由的名字.需要重定向示图函数的名字',参数名=参数名))
@blue点的是示图函数的名字不是路由的名字