概述
def my_method(): do_stuff section = Blueprint('section',__name__) # Register my_method() as a setup method that runs before all routes section.custom_setup_method(my_method()) @section.route('/two') def route_one(): do_stuff @section.route('/one') def route_two(): do_stuff
然后基本上/ section / one和/ section / two将在执行route_one()或route_two()中的代码之前运行my_method().
有没有办法做到这一点?
@section.before_request def my_method(): do_stuff
总结
以上是编程之家为你收集整理的python – Flask:如何在蓝图中的每个路径之前运行方法?全部内容,希望文章能够帮你解决python – Flask:如何在蓝图中的每个路径之前运行方法?所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧