Refactored the @route decorator to use the new add_url_rule method.
Tagged add_url_rule with versionadded of 0.2
This commit is contained in:
parent
3088a9371e
commit
5acc491c94
1 changed files with 3 additions and 2 deletions
5
flask.py
5
flask.py
|
|
@ -508,6 +508,8 @@ class Flask(object):
|
||||||
:param view_func: the function to call when servicing a request to the provided endpoint
|
:param view_func: the function to call when servicing a request to the provided endpoint
|
||||||
:param options: the options to be forwarded to the underlying
|
:param options: the options to be forwarded to the underlying
|
||||||
:class:`~werkzeug.routing.Rule` object
|
:class:`~werkzeug.routing.Rule` object
|
||||||
|
|
||||||
|
.. versionadded:: 0.2
|
||||||
"""
|
"""
|
||||||
options['endpoint'] = endpoint
|
options['endpoint'] = endpoint
|
||||||
options.setdefault('methods', ('GET',))
|
options.setdefault('methods', ('GET',))
|
||||||
|
|
@ -581,8 +583,7 @@ class Flask(object):
|
||||||
:class:`~werkzeug.routing.Rule` object.
|
:class:`~werkzeug.routing.Rule` object.
|
||||||
"""
|
"""
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
self.add_url_rule(rule, f.__name__, **options)
|
self.add_url_rule(rule, f.__name__, f, **options)
|
||||||
self.view_functions[f.__name__] = f
|
|
||||||
return f
|
return f
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue