flask中url_for使用endpoint和视图函数名
2021-04-08 23:27
                         标签:point   函数名   反转   地址   page   url   使用   end   return    在flask中,使用url_for 进行路由反转时,需要传递一个endpoint的值,用法如下: @app.route(‘/‘, endpoint=‘my_index‘) def index():   return ‘index page‘ @app.route(‘/hello‘) def hello():   return url_for(‘.my_index‘, _external=True)   说明: 1.在url_for 反转时,接受一个endpoint或者函数名为参数(如果是endpoint,endpoint前面需要加个点),返回对应的url地址(可看源码) 2.在前端页面如果使用url_for的时候,也需要加上点,如:{{ url_for(‘.my_index‘) }} 3._external=True 如果设置为 flask中url_for使用endpoint和视图函数名 标签:point   函数名   反转   地址   page   url   使用   end   return    原文地址:https://www.cnblogs.com/lishuaijiang/p/12454610.htmlTrue,则生成一个绝对路径URL
文章标题:flask中url_for使用endpoint和视图函数名
文章链接:http://soscw.com/index.php/essay/73081.html