docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
@pytest.mark.parametrize('config_key',
['TESTING', 'PROPAGATE_EXCEPTIONS', 'DEBUG', None])
def test_exception_propagation(config_key):
app = flask.Flask(__name__)
app.config['LOGGER_HANDLER_POLICY'] = 'never' | <mask> rv = app.test_client().get('/', 'http://foo.localhost.localdomain')
<mask> assert rv.data == b'Foo SubDomain'
<mask>
<mask>
<mask> def test_exception_propagation():
<mask> def apprunner(configkey):
<mask> app = flask.Flask(__name__)
<mask> app.config['LOGGER_HANDLER_POLICY']... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/78cd4161f0a264df89046b6324446b27011b0930 | tests/test_basic.py |
@app.route('/')
def index():
1 // 0
c = app.test_client() | <mask> def apprunner(configkey):
<mask> app = flask.Flask(__name__)
<mask> app.config['LOGGER_HANDLER_POLICY'] = 'never'
<mask>
<mask> @app.route('/')
<mask> def index():
<mask> 1 // 0
<mask> c = app.test_client()
<mask> if config_key is not None... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/78cd4161f0a264df89046b6324446b27011b0930 | tests/test_basic.py |
if config_key is not None:
app.config[config_key] = True
with pytest.raises(Exception):
c.get('/') | <mask> assert False, 'expected exception'
<mask> else:
<mask> assert c.get('/').status_code == 500
<mask>
<mask> # we have to run this test in an isolated thread because if the
<mask> # debug flag is set to true and an exception happens the context is
<mask> # not... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/78cd4161f0a264df89046b6324446b27011b0930 | tests/test_basic.py |
else:
assert c.get('/').status_code == 500
# If the debug flag is set to true and an exception happens the context
# is not torn down. This causes other tests that run after this fail
# when they expect no exception on the stack.
while flask._request_ctx_stack.top is not None:
flas... | <mask> app.config[config_key] = True
<mask> with pytest.raises(Exception):
<mask> c.get('/')
<mask>
<mask>
<mask> def test_max_content_length():
<mask> app = flask.Flask(__name__)
<mask> app.config['MAX_CONTENT_LENGTH'] = 64
<mask>
</s> Don't use threads in this test
I ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/78cd4161f0a264df89046b6324446b27011b0930 | tests/test_basic.py |
- Autoescaping is now enabled by default for ``.svg`` files. Inside
templates this behavior can be changed with the ``autoescape`` tag.
:issue:`4831` | <mask> Unreleased
<mask>
<mask> - Fix the type of ``template_folder`` to accept ``pathlib.Path``. :issue:`4892`
<mask>
<mask>
<mask> Version 2.2.2
<mask> -------------
</s> Add .svg to select_jinja_autoescape (#4840)
As SVG files are a type of XML file and are similar in nearly
all aspects to XML, .svg sh... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/79032ca5f1c4747e5aeaa193bdeb2e4eae410ea6 | CHANGES.rst |
``.htm``, ``.xml``, ``.xhtml``, as well as ``.svg`` when using | <mask>
<mask> Unless customized, Jinja2 is configured by Flask as follows:
<mask>
<mask> - autoescaping is enabled for all templates ending in ``.html``,
<mask> ``.htm``, ``.xml`` as well as ``.xhtml`` when using
<mask> :func:`~flask.templating.render_template`.
<mask> - autoescaping is enabled for... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/79032ca5f1c4747e5aeaa193bdeb2e4eae410ea6 | docs/templating.rst |
.. versionchanged:: 2.2
Autoescaping is now enabled by default for ``.svg`` files.
| <mask> """Returns ``True`` if autoescaping should be active for the given
<mask> template name. If no template name is given, returns `True`.
<mask>
<mask> .. versionadded:: 0.5
<mask> """
<mask> if filename is None:
<mask> return True
<mask> return f... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/79032ca5f1c4747e5aeaa193bdeb2e4eae410ea6 | src/flask/app.py |
return filename.endswith((".html", ".htm", ".xml", ".xhtml", ".svg")) | <mask> .. versionadded:: 0.5
<mask> """
<mask> if filename is None:
<mask> return True
<mask> return filename.endswith((".html", ".htm", ".xml", ".xhtml"))
<mask>
<mask> def update_template_context(self, context: dict) -> None:
<mask> """Update the templa... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/79032ca5f1c4747e5aeaa193bdeb2e4eae410ea6 | src/flask/app.py |
from .module import blueprint_is_module | <mask> from .config import ConfigAttribute, Config
<mask> from .ctx import RequestContext
<mask> from .globals import _request_ctx_stack, request
<mask> from .session import Session, _NullSession
<mask> from .module import _ModuleSetupState
<mask> from .templating import DispatchingJinjaLoader, Environment, \
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
<mask> #: The class that is used for response objects. See
<mask> #: :class:`~flask.Response` for more information.
<mask> response_class = Response
<mask>
<mask> #: Path for the static files. If you don't want to use static files
<mask> #: you can set this value to `None` in which case no ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py | |
def __init__(self, import_name, static_path=None, static_url_path=None,
static_folder='static'): | <mask> #:
<mask> #: .. versionadded:: 0.7
<mask> test_client_class = None
<mask>
<mask> def __init__(self, import_name, static_path=None):
<mask> _PackageBoundObject.__init__(self, import_name)
<mask> if static_path is not None:
<mask> self.static_path = static_path
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
from warnings import warn
warn(DeprecationWarning('static_path is now called '
'static_url_path'), stacklevel=2)
static_url_path = static_path
if static_url_path is not None:
self.static_url_path = static_url_path
if st... | <mask>
<mask> def __init__(self, import_name, static_path=None):
<mask> _PackageBoundObject.__init__(self, import_name)
<mask> if static_path is not None:
<mask> self.static_path = static_path
<mask>
<mask> #: The configuration dictionary as :class:`Config`. This behave... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
#: the blueprint this function is active for, `None` for all requests. | <mask> self.error_handlers = {}
<mask>
<mask> #: A dictionary with lists of functions that should be called at the
<mask> #: beginning of the request. The key of the dictionary is the name of
<mask> #: the module this function is active for, `None` for all requests.
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
#: each request. The key of the dictionary is the name of the blueprint | <mask> #: function here, use the :meth:`before_request` decorator.
<mask> self.before_request_funcs = {}
<mask>
<mask> #: A dictionary with lists of functions that should be called after
<mask> #: each request. The key of the dictionary is the name of the module
<mask> #:... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
#: dictionary is the name of the blueprint this function is active for, | <mask> self.after_request_funcs = {}
<mask>
<mask> #: A dictionary with lists of functions that are called after
<mask> #: each request, even if an exception has occurred. The key of the
<mask> #: dictionary is the name of the module this function is active for,
<mask> #: ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
#: name of the blueprint this function is active for, `None` for all | <mask> self.teardown_request_funcs = {}
<mask>
<mask> #: A dictionary with list of functions that are called without argument
<mask> #: to populate the template context. The key of the dictionary is the
<mask> #: name of the module this function is active for, `None` for all
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
<mask> self.template_context_processors = {
<mask> None: [_default_template_ctx_processor]
<mask> }
<mask>
<mask> #: all the loaded modules in a dictionary by name.
<mask> #:
<mask> #: .. versionadded:: 0.5
<mask> self.modules = {}
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py | |
if self.has_static_folder:
self.add_url_rule(self.static_url_path + '/<path:filename>',
endpoint='static',
view_func=self.send_static_file) | <mask> # if the folder does not exist. First of all it might be created
<mask> # while the server is running (usually happens during development)
<mask> # but also because google appengine stores static files somewhere
<mask> # else when mapped with the .yml file.
<mask> se... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
bp = _request_ctx_stack.top.request.blueprint
if bp is not None and bp in self.template_context_processors:
funcs = chain(funcs, self.template_context_processors[bp]) | <mask> :param context: the context as a dictionary that is updated in place
<mask> to add extra variables.
<mask> """
<mask> funcs = self.template_context_processors[None]
<mask> mod = _request_ctx_stack.top.request.module
<mask> if mod is not None a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
assert blueprint_is_module(module), 'register_module requires ' \
'actual module objects. Please upgrade to blueprints though.' | <mask> The module system was deprecated in favor for the blueprint
<mask> system.
<mask> """
<mask> if not self.enable_modules:
<mask> raise RuntimeError('Module support was disabled but code '
<mask> 'attempted to register a module named %r' % mod... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
self.register_blueprint(module, **options) | <mask> 'Flask-Extension upgrade the extension or contact the author '
<mask> 'of that extension instead. (Registered %r)' % module),
<mask> stacklevel=2)
<mask>
<mask> options.setdefault('url_prefix', module.url_prefix)
<mask> options.setdefault('s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
bp = request.blueprint
if bp is not None and bp in self.before_request_funcs:
funcs = chain(funcs, self.before_request_funcs[bp]) | <mask> if it was the return value from the view and further
<mask> request handling is stopped.
<mask> """
<mask> funcs = self.before_request_funcs.get(None, ())
<mask> mod = request.module
<mask> if mod and mod in self.before_request_funcs:
<mask> func... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
bp = ctx.request.blueprint | <mask> :return: a new response object or the same, has to be an
<mask> instance of :attr:`response_class`.
<mask> """
<mask> ctx = _request_ctx_stack.top
<mask> mod = ctx.request.module
<mask> if not isinstance(ctx.session, _NullSession):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
if bp is not None and bp in self.after_request_funcs:
funcs = reversed(self.after_request_funcs[bp]) | <mask> mod = ctx.request.module
<mask> if not isinstance(ctx.session, _NullSession):
<mask> self.save_session(ctx.session, response)
<mask> funcs = ()
<mask> if mod and mod in self.after_request_funcs:
<mask> funcs = reversed(self.after_request_funcs[mod])
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
bp = request.blueprint
if bp is not None and bp in self.teardown_request_funcs:
funcs = chain(funcs, reversed(self.teardown_request_funcs[bp])) | <mask> triggered when the request context is popped. That way we have a
<mask> tighter control over certain resources under testing environments.
<mask> """
<mask> funcs = reversed(self.teardown_request_funcs.get(None, ()))
<mask> mod = request.module
<mask> if mod... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
@property
def modules(self):
from warnings import warn
warn(DeprecationWarning('Flask.modules is deprecated, use '
'Flask.blueprints instead'), stacklevel=2)
return self.blueprints
| <mask> return response(environ, start_response)
<mask>
<mask> def __call__(self, environ, start_response):
<mask> """Shortcut for :attr:`wsgi_app`."""
<mask> return self.wsgi_app(environ, start_response)
</s> Latest iteration of the blueprint code. Far from being done </s> remove... | [
"keep",
"add",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/app.py |
from .module import blueprint_is_module | <mask> from werkzeug.exceptions import HTTPException
<mask>
<mask> from .globals import _request_ctx_stack
<mask> from .session import _NullSession
<mask>
<mask>
<mask> class _RequestGlobals(object):
<mask> pass
<mask>
<mask>
</s> Latest iteration of the blueprint code. Far from being done </s> rem... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/ctx.py |
# Support for deprecated functionality. This is doing away with
# Flask 1.0
blueprint = self.request.blueprint
if blueprint is not None:
# better safe than sorry, we don't want to break code that
# already worked
bp = app.blueprints.get(blueprint)
... | <mask> self.request.url_rule = url_rule
<mask> except HTTPException, e:
<mask> self.request.routing_exception = e
<mask>
<mask> def push(self):
<mask> """Binds the request context to the current context."""
<mask> _request_ctx_stack.push(self)
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/ctx.py |
<mask>
<mask>
<mask> def url_for(endpoint, **values):
<mask> """Generates a URL to the given endpoint with the method provided.
<mask> The endpoint is relative to the active module if modules are in use.
<mask>
<mask> Here are some examples:
<mask>
<mask> ==================== ==============... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/helpers.py | |
if not ctx.request._is_old_module:
if endpoint[:1] == '.':
endpoint = request.blueprint + endpoint
else:
# TODO: get rid of this deprecated functionality in 1.0
if '.' not in endpoint:
mod = ctx.request.blueprint
if mod is not None:
end... | <mask> :param values: the variable arguments of the URL rule
<mask> :param _external: if set to `True`, an absolute URL is generated.
<mask> """
<mask> ctx = _request_ctx_stack.top
<mask> if '.' not in endpoint:
<mask> mod = ctx.request.module
<mask> if mod is not None:
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/helpers.py |
template_folder = 'templates'
| <mask> class _PackageBoundObject(object):
<mask>
<mask> def __init__(self, import_name):
<mask> #: The name of the package or module. Do not change this once
<mask> #: it was set by the constructor.
<mask> self.import_name = import_name
</s> Latest iteration of the blueprint code. ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/helpers.py |
return self.static_folder is not None | <mask> folder named ``'static'``.
<mask>
<mask> .. versionadded:: 0.5
<mask> """
<mask> return os.path.isdir(os.path.join(self.root_path, 'static'))
<mask>
<mask> @locked_cached_property
<mask> def jinja_loader(self):
<mask> """The Jinja loader for this package... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/helpers.py |
if self.template_folder is not None:
return FileSystemLoader(os.path.join(self.root_path,
self.template_folder)) | <mask> """The Jinja loader for this package bound object.
<mask>
<mask> .. versionadded:: 0.5
<mask> """
<mask> return FileSystemLoader(os.path.join(self.root_path, 'templates'))
<mask>
<mask> def send_static_file(self, filename):
<mask> """Function used internally ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/helpers.py |
if not self.has_static_folder:
raise RuntimeError('No static folder for this object') | <mask> .. versionadded:: 0.5
<mask> """
<mask> return send_from_directory(os.path.join(self.root_path, 'static'),
<mask> filename)
<mask>
<mask> def open_resource(self, resource):
</s> Latest iteration of the blueprint code. Far from being done </s... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/helpers.py |
import os | <mask> :copyright: (c) 2010 by Armin Ronacher.
<mask> :license: BSD, see LICENSE for more details.
<mask> """
<mask>
<mask> from .helpers import _PackageBoundObject, _endpoint_from_view_func
<mask>
<mask>
<mask> def _register_module(module, static_path):
<mask> """Internal helper function that r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py |
from .helpers import _PackageBoundObject, _endpoint_from_view_func
from .blueprints import Blueprint | <mask> app.register_module(frontend)
<mask>
<mask> And here's an example view module (`myapplication/views/admin.py`)::
<mask>
<mask> from flask import Module
<mask>
<mask> admin = Module(__name__)
<mask>
<mask> @admin.route('/')
<mask> def index():
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py |
<mask> @admin.route('/')
<mask> def index():
<mask> pass
<mask>
<mask> @admin.route('/login')
<mask> def login():
<mask> pass
<mask>
<mask> For a gentle introduction into modules, checkout the
<mask> :ref:`working-with-modules` section.
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py | |
def blueprint_is_module(bp):
"""Used to figure out if something is actually a module"""
return isinstance(bp, Module) | <mask> @admin.route('/login')
<mask> def login():
<mask> pass
<mask>
<mask> For a gentle introduction into modules, checkout the
<mask> :ref:`working-with-modules` section.
<mask>
<mask> .. versionadded:: 0.5
<mask> The `static_path` parameter was added and it's... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py |
<mask>
<mask> For a gentle introduction into modules, checkout the
<mask> :ref:`working-with-modules` section.
<mask>
<mask> .. versionadded:: 0.5
<mask> The `static_path` parameter was added and it's now possible for
<mask> modules to refer to their own templates and static files. S... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py | |
class Module(Blueprint):
"""Deprecated module support. Until Flask 0.6 modules were a different
name of the concept now available as blueprints in Flask. They are
essentially doing the same but have some bad semantics for templates and
static files that were fixed with blueprints. | <mask> The `static_path` parameter was added and it's now possible for
<mask> modules to refer to their own templates and static files. See
<mask> :ref:`modules-and-resources` for more information.
<mask>
<mask> .. versionadded:: 0.6
<mask> The `subdomain` parameter was added.
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py |
.. versionchanged:: 0.7
Modules were deprecated in favor for blueprints. | <mask>
<mask> .. versionadded:: 0.6
<mask> The `subdomain` parameter was added.
<mask>
<mask> :param import_name: the name of the Python package or module
<mask> implementing this :class:`Module`.
<mask> :param name: the internal short name for the module. Unless spe... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py |
Blueprint.__init__(self, name, import_name, url_prefix=url_prefix,
subdomain=subdomain) | <mask> if name is None:
<mask> assert '.' in import_name, 'name required if package name ' \
<mask> 'does not point to a submodule'
<mask> name = import_name.rsplit('.', 1)[1]
<mask> _PackageBoundObject.__init__(self, import_name)
<mask> self.name = ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py |
if os.path.isdir(os.path.join(self.root_path, 'static')):
self._static_folder = 'static' | <mask> self._record(lambda s: s.app.errorhandler(code)(f))
<mask> return f
<mask> return decorator
<mask>
<mask> def _record(self, func):
<mask> self._register_events.append(func)
</s> Latest iteration of the blueprint code. Far from being done </s> remove _P... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/module.py |
from .module import blueprint_is_module | <mask> from .globals import _request_ctx_stack
<mask> from .signals import template_rendered
<mask>
<mask>
<mask> def _default_template_ctx_processor():
<mask> """Default template context processor. Injects `request`,
</s> Latest iteration of the blueprint code. Far from being done </s> remove from .modu... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/templating.py |
blueprint = self.app.blueprints[module]
if blueprint_is_module(blueprint):
loader = blueprint.jinja_loader | <mask> # and try that before we go with the real deal.
<mask> loader = None
<mask> try:
<mask> module, name = posixpath.normpath(template).split('/', 1)
<mask> loader = self.app.modules[module].jinja_loader
<mask> except (ValueError, KeyError, TemplateNotFou... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/templating.py |
# switched by the request context until 1.0 to opt in deprecated
# module functionality
_is_old_module = False
| <mask> routing_exception = None
<mask>
<mask> @property
<mask> def max_content_length(self):
<mask> """Read-only view of the `MAX_CONTENT_LENGTH` config key."""
<mask> ctx = _request_ctx_stack.top
<mask> if ctx is not None:
</s> Latest iteration of the blueprint code. Far f... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/wrappers.py |
"""The name of the current module if the request was dispatched
to an actual module. This is deprecated functionality, use blueprints
instead.
"""
from warnings import warn
warn(DeprecationWarning('modules were deprecated in favor of '
'bl... | <mask> return self.url_rule.endpoint
<mask>
<mask> @property
<mask> def module(self):
<mask> """The name of the current module"""
<mask> if self.url_rule and \
<mask> ':' not in self.url_rule.endpoint and \
<mask> '.' in self.url_rule.endpoint:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/wrappers.py |
if self.url_rule and '.' in self.url_rule.endpoint:
return self.url_rule.endpoint.split('.', 1)[0] | <mask>
<mask> @property
<mask> def blueprint(self):
<mask> """The name of the current blueprint"""
<mask> if self.url_rule and ':' in self.url_rule.endpoint:
<mask> return self.url_rule.endpoint.split(':', 1)[0]
<mask>
<mask> @cached_property
<mask> def json(self):... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | flask/wrappers.py |
app.testing = True | <mask>
<mask> app = flask.Flask(__name__)
<mask> app.url_map.add(Submount('/foo', [
<mask> Rule('/bar', endpoint='bar'),
<mask> Rule('/', endpoint='index')
<mask> ]))
</s> Latest iteration of the blueprint code. Far from being done </s> remove from .helpers impor... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a08331ac062ee1e2ae3c7547f77c2d342ddb3df | tests/flask_tests.py |
sphinx==4.1.2 | <mask> # tox
<mask> # virtualenv
<mask> snowballstemmer==2.1.0
<mask> # via sphinx
<mask> sphinx==4.0.2
<mask> # via
<mask> # -r requirements/docs.in
<mask> # pallets-sphinx-themes
<mask> # sphinx-issues
<mask> # sphinx-tabs
</s> Bump sphinx from 4.0.2 to 4.1.2
Bu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a3b8bbb897991a791ce51a870866648577054b9 | requirements/dev.txt |
sphinxcontrib-htmlhelp==2.0.0 | <mask> sphinxcontrib-applehelp==1.0.2
<mask> # via sphinx
<mask> sphinxcontrib-devhelp==1.0.2
<mask> # via sphinx
<mask> sphinxcontrib-htmlhelp==1.0.3
<mask> # via sphinx
<mask> sphinxcontrib-jsmath==1.0.1
<mask> # via sphinx
<mask> sphinxcontrib-log-cabinet==1.0.1
<mask> # via -r requirem... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a3b8bbb897991a791ce51a870866648577054b9 | requirements/dev.txt |
sphinxcontrib-serializinghtml==1.1.5 | <mask> sphinxcontrib-log-cabinet==1.0.1
<mask> # via -r requirements/docs.in
<mask> sphinxcontrib-qthelp==1.0.3
<mask> # via sphinx
<mask> sphinxcontrib-serializinghtml==1.1.4
<mask> # via sphinx
<mask> toml==0.10.2
<mask> # via
<mask> # mypy
<mask> # pep517
</s> Bump sphinx from ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a3b8bbb897991a791ce51a870866648577054b9 | requirements/dev.txt |
sphinx==4.1.2 | <mask> requests==2.25.1
<mask> # via sphinx
<mask> snowballstemmer==2.1.0
<mask> # via sphinx
<mask> sphinx==4.0.2
<mask> # via
<mask> # -r requirements/docs.in
<mask> # pallets-sphinx-themes
<mask> # sphinx-issues
<mask> # sphinx-tabs
</s> Bump sphinx from 4.0.2 to 4.1.2
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a3b8bbb897991a791ce51a870866648577054b9 | requirements/docs.txt |
sphinxcontrib-htmlhelp==2.0.0 | <mask> sphinxcontrib-applehelp==1.0.2
<mask> # via sphinx
<mask> sphinxcontrib-devhelp==1.0.2
<mask> # via sphinx
<mask> sphinxcontrib-htmlhelp==1.0.3
<mask> # via sphinx
<mask> sphinxcontrib-jsmath==1.0.1
<mask> # via sphinx
<mask> sphinxcontrib-log-cabinet==1.0.1
<mask> # via -r requirem... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a3b8bbb897991a791ce51a870866648577054b9 | requirements/docs.txt |
sphinxcontrib-serializinghtml==1.1.5 | <mask> sphinxcontrib-log-cabinet==1.0.1
<mask> # via -r requirements/docs.in
<mask> sphinxcontrib-qthelp==1.0.3
<mask> # via sphinx
<mask> sphinxcontrib-serializinghtml==1.1.4
<mask> # via sphinx
<mask> urllib3==1.26.5
<mask> # via requests
<mask>
<mask> # The following packages are considere... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a3b8bbb897991a791ce51a870866648577054b9 | requirements/docs.txt |
<mask> - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
<mask> - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
<mask> - {name: '3.6', python: '3.6', os: ubuntu-latest, tox: py36}
<mask> - {name: 'PyPy', python: pypy3, os: ubuntu-latest, tox: pypy3}
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | .github/workflows/tests.yaml | |
from copy import copy | <mask> from contextlib import contextmanager
<mask>
<mask> import werkzeug.test
<mask> from click.testing import CliRunner
<mask> from werkzeug.test import Client
<mask> from werkzeug.urls import url_parse
<mask> from werkzeug.wrappers import BaseRequest
</s> update tests for new werkzeug client (#3827)
Flask... | [
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | src/flask/testing.py |
from werkzeug.wrappers import BaseRequest | <mask> from werkzeug.test import Client
<mask> from werkzeug.urls import url_parse
<mask>
<mask> from . import _request_ctx_stack
<mask> from .cli import ScriptInfo
<mask> from .json import dumps as json_dumps
<mask>
<mask>
</s> update tests for new werkzeug client (#3827)
Flask's client.open mirrors Werkz... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | src/flask/testing.py |
def open(
self, *args, as_tuple=False, buffered=False, follow_redirects=False, **kwargs
):
# Same logic as super.open, but apply environ_base and preserve_context.
request = None
def copy_environ(other):
return {
**self.environ_base,
*... | <mask> session_interface.save_session(app, sess, resp)
<mask> headers = resp.get_wsgi_headers(c.request.environ)
<mask> self.cookie_jar.extract_wsgi(c.request.environ, headers)
<mask>
<mask> def open(self, *args, **kwargs):
<mask> as_tuple = kwargs.pop("as_tupl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | src/flask/testing.py |
request = builder.get_request() | <mask> kwargs.setdefault("environ_base", self.environ_base)
<mask> builder = EnvironBuilder(self.application, *args, **kwargs)
<mask>
<mask> try:
<mask> environ = builder.get_environ()
<mask> finally:
<mask> builder.close()
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | src/flask/testing.py |
return super().open(
request, | <mask> environ = builder.get_environ()
<mask> finally:
<mask> builder.close()
<mask>
<mask> return Client.open(
<mask> self,
<mask> environ,
<mask> as_tuple=as_tuple,
<mask> buffered=buffered,
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | src/flask/testing.py |
<mask> [tox]
<mask> envlist =
<mask> py{39,38,37,36,py3}
<mask> py38-devel
<mask> style
<mask> docs
<mask> skip_missing_interpreters = true
<mask>
<mask> [testenv]
</s> update tests for new werkzeug client (#3827)
Flask's client.open mirrors Werkzeug's for processing an existing
environ.
... | [
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | tox.ini | |
ERROR: type should be string, got " https://github.com/pallets/werkzeug/archive/master.tar.gz\n https://github.com/pallets/markupsafe/archive/master.tar.gz\n https://github.com/pallets/jinja/archive/master.tar.gz\n https://github.com/pallets/itsdangerous/archive/master.tar.gz\n https://github.com/pallets/click/archive/master.tar.gz" | <mask> [testenv]
<mask> deps =
<mask> -r requirements/tests.txt
<mask>
<mask> devel: https://github.com/pallets/werkzeug/archive/master.tar.gz
<mask> devel: https://github.com/pallets/markupsafe/archive/master.tar.gz
<mask> devel: https://github.com/pallets/jinja/archive/master.tar.gz
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7a444c5dab97d640282ec8fc4838bef2c128273f | tox.ini |
- Add ``routes`` CLI command to output routes registered on the application.
(`#2259`_) | <mask> override the app's encoder and decoder. (`#1898`_)
<mask> - ``Flask.make_response`` raises ``TypeError`` instead of ``ValueError`` for
<mask> bad response types. The error messages have been improved to describe why the
<mask> type is invalid. (`#2256`_)
<mask>
<mask> .. _#1489: https://github.com/p... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | CHANGES |
.. _#2259: https://github.com/pallets/flask/pull/2259 | <mask> .. _#2223: https://github.com/pallets/flask/pull/2223
<mask> .. _#2254: https://github.com/pallets/flask/pull/2254
<mask> .. _#2256: https://github.com/pallets/flask/pull/2256
<mask>
<mask> Version 0.12.1
<mask> --------------
<mask>
</s> add sort by match order
sort by endpoint by default
combine sort... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | CHANGES |
<mask>
<mask> import os
<mask> import sys
<mask> import traceback
<mask> from threading import Lock, Thread
<mask> from functools import update_wrapper
<mask>
<mask> import click
<mask>
<mask> from ._compat import iteritems, reraise
</s> add sort by match order
sort by endpoint by default
combine sort fla... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py | |
from operator import attrgetter
from threading import Lock, Thread | <mask> import sys
<mask> import traceback
<mask> from functools import update_wrapper
<mask>
<mask> import click
<mask>
<mask> from . import __version__
</s> add sort by match order
sort by endpoint by default
combine sort flags
sort methods
ignore HEAD and OPTIONS methods by default
rearrange columns
use for... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py |
from . import __version__ | <mask>
<mask> import click
<mask>
<mask> from ._compat import iteritems, reraise
<mask> from .globals import current_app
<mask> from .helpers import get_debug_flag
<mask>
<mask>
</s> add sort by match order
sort by endpoint by default
combine sort flags
sort methods
ignore HEAD and OPTIONS methods by defau... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py |
from .globals import current_app | <mask>
<mask> from . import __version__
<mask> from ._compat import iteritems, reraise
<mask> from .helpers import get_debug_flag
<mask>
<mask>
<mask> class NoAppException(click.UsageError):
<mask> """Raised if an application cannot be found or loaded."""
</s> add sort by match order
sort by endpoint by... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py |
<mask> import click
<mask>
<mask> from ._compat import iteritems, reraise
<mask> from .helpers import get_debug_flag
<mask> from . import __version__
<mask>
<mask> class NoAppException(click.UsageError):
<mask> """Raised if an application cannot be found or loaded."""
<mask>
<mask>
</s> add sort by m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py | |
@click.command('routes', short_help='Show the routes for the app.')
@click.option(
'--sort', '-s',
type=click.Choice(('endpoint', 'methods', 'rule', 'match')),
default='endpoint',
help=(
'Method to sort routes by. "match" is the order that Flask will match '
'routes when dispatching a re... | <mask>
<mask> code.interact(banner=banner, local=ctx)
<mask>
<mask>
<mask> @click.command('routes', short_help='Show routes for the app.')
<mask> @click.option('-r', 'order_by', flag_value='rule', default=True, help='Order by route')
<mask> @click.option('-e', 'order_by', flag_value='endpoint', help='Orde... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py |
def routes_command(sort, all_methods):
"""Show all registered routes with endpoints and methods."""
rules = list(current_app.url_map.iter_rules())
ignored_methods = set(() if all_methods else ('HEAD', 'OPTIONS'))
if sort in ('endpoint', 'rule'):
rules = sorted(rules, key=attrgetter(sort))
... | <mask> @click.option('-r', 'order_by', flag_value='rule', default=True, help='Order by route')
<mask> @click.option('-e', 'order_by', flag_value='endpoint', help='Order by endpoint')
<mask> @click.option('-m', 'order_by', flag_value='methods', help='Order by methods')
<mask> @with_appcontext
<mask> def routes_comm... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py |
click.echo(row.format(*headers).strip())
click.echo(row.format(*('-' * width for width in widths))) | <mask> max_ep = max(max_ep, len('Endpoint'))
<mask> max_meth = max(len(', '.join(rule.methods)) for rule in sorted_rules)
<mask> max_meth = max(max_meth, len('Methods'))
<mask>
<mask> columnformat = '{:<%s} {:<%s} {:<%s}' % (max_rule, max_ep, max_meth)
<mask> click.echo(columnformat.format(... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py |
for rule, methods in zip(rules, rule_methods):
click.echo(row.format(rule.endpoint, methods, rule.rule).rstrip()) | <mask> click.echo(columnformat.format('Route', 'Endpoint', 'Methods'))
<mask> under_count = max_rule + max_ep + max_meth + 4
<mask> click.echo('-' * under_count)
<mask>
<mask> for rule in sorted_rules:
<mask> methods = ', '.join(rule.methods)
<mask> click.echo(columnformat.format... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | flask/cli.py |
from functools import partial | <mask> from __future__ import absolute_import, print_function
<mask> import os
<mask> import sys
<mask>
<mask> import click
<mask> import pytest
<mask> from click.testing import CliRunner
</s> add sort by match order
sort by endpoint by default
combine sort flags
sort methods
ignore HEAD and OPTIONS methods by... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | tests/test_cli.py |
def test_print_exceptions(runner): | <mask> assert result.exit_code == 0
<mask> assert result.output == 'flaskgroup\n'
<mask>
<mask>
<mask> def test_print_exceptions():
<mask> """Print the stacktrace if the CLI."""
<mask> def create_app(info):
<mask> raise Exception("oh no")
<mask> return Flask("flaskgroup")
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | tests/test_cli.py |
<mask> @click.group(cls=FlaskGroup, create_app=create_app)
<mask> def cli(**params):
<mask> pass
<mask>
<mask> runner = CliRunner()
<mask> result = runner.invoke(cli, ['--help'])
<mask> assert result.exit_code == 0
<mask> assert 'Exception: oh no' in result.output
<mask> as... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | tests/test_cli.py | |
@pytest.fixture
def invoke(self, runner):
def create_app(info):
app = Flask(__name__)
app.testing = True | <mask> assert 'Traceback' in result.output
<mask>
<mask>
<mask> class TestRoutes:
<mask> def test_no_route(self, runner, monkeypatch):
<mask> monkeypatch.setitem(os.environ, 'FLASK_APP', 'cliapp.routesapp:noroute_app')
<mask> result = runner.invoke(cli, ['routes'], catch_exceptions=Fals... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | tests/test_cli.py |
@app.route('/get_post/<int:x>/<int:y>', methods=['GET', 'POST'])
def yyy_get_post(x, y):
pass
@app.route('/zzz_post', methods=['POST'])
def aaa_post():
pass | <mask> -----------------------------------------------------
<mask> /static/<path:filename> static HEAD, OPTIONS, GET
<mask> """
<mask>
<mask> def test_simple_route(self, runner, monkeypatch):
<mask> monkeypatch.setitem(os.environ, 'FLASK_APP', 'cliapp.routesapp:simpleroute_app')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | tests/test_cli.py |
return app
cli = FlaskGroup(create_app=create_app)
return partial(runner.invoke, cli)
def expect_order(self, order, output):
# skip the header and match the start of each row
for expect, line in zip(order, output.splitlines()[2:]):
# do this instead of start... | <mask> /simpleroute simple HEAD, OPTIONS, GET
<mask> /static/<path:filename> static HEAD, OPTIONS, GET
<mask> """
<mask>
<mask> def test_only_POST_route(self, runner, monkeypatch):
<mask> monkeypatch.setitem(os.environ, 'FLASK_APP', 'cliapp.routesapp:only_POST_route_app')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | tests/test_cli.py |
self.expect_order(
['aaa_post', 'static', 'yyy_get_post'],
result.output
)
def test_sort(self, invoke):
default_output = invoke(['routes']).output
endpoint_output = invoke(['routes', '-s', 'endpoint']).output
assert default_output == endpoint_output
... | <mask> def test_only_POST_route(self, runner, monkeypatch):
<mask> monkeypatch.setitem(os.environ, 'FLASK_APP', 'cliapp.routesapp:only_POST_route_app')
<mask> result = runner.invoke(cli, ['routes'], catch_exceptions=False)
<mask> assert result.exit_code == 0
<mask> assert result... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/pallets/flask/commit/7ad79583b9558cc7806d56c534f9527e500734e9 | tests/test_cli.py |
- When loading a ``.env`` or ``.flaskenv`` file, the current working
directory is no longer changed to the location of the file.
:pr:`3560`
- When returning a ``(response, headers)`` tuple from a view, the
headers replace rather than extend existing headers on the response.
For example, this allows ... | <mask> - When using ad-hoc certificates, check for the cryptography library
<mask> instead of PyOpenSSL. :pr:`3492`
<mask> - When specifying a factory function with ``FLASK_APP``, keyword
<mask> argument can be passed. :issue:`3553`
<mask> - When loading a ``.env`` or ``.flaskenv`` file on top level ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b09a0904c32dc8784cdd68e842442057340a361 | CHANGES.rst |
rv.headers.update(headers) | <mask> rv.status_code = status
<mask>
<mask> # extend existing headers with provided headers
<mask> if headers:
<mask> rv.headers.extend(headers)
<mask>
<mask> return rv
<mask>
<mask> def create_url_adapter(self, request):
<mask> """Creates a ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b09a0904c32dc8784cdd68e842442057340a361 | src/flask/app.py |
flask.Response(
"Hello world", 404, {"Content-Type": "text/html", "X-Foo": "Baz"}
),
{"Content-Type": "text/plain", "X-Foo": "Bar", "X-Bar": "Foo"}, | <mask>
<mask> @app.route("/response_headers")
<mask> def from_response_headers():
<mask> return (
<mask> flask.Response("Hello world", 404, {"X-Foo": "Baz"}),
<mask> {"X-Foo": "Bar", "X-Bar": "Foo"},
<mask> )
<mask>
<mask> @app.route("/response_status")
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b09a0904c32dc8784cdd68e842442057340a361 | tests/test_basic.py |
assert rv.content_type == "text/plain"
assert rv.headers.getlist("X-Foo") == ["Bar"] | <mask> assert rv.mimetype == "text/html"
<mask>
<mask> rv = client.get("/response_headers")
<mask> assert rv.data == b"Hello world"
<mask> assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]
<mask> assert rv.headers["X-Bar"] == "Foo"
<mask> assert rv.status_code == 404
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b09a0904c32dc8784cdd68e842442057340a361 | tests/test_basic.py |
<mask> import os
<mask> import sys
<mask>
<mask> from threading import local
<mask> from contextlib import contextmanager
<mask> from jinja2 import Environment, PackageLoader, FileSystemLoader
<mask> from werkzeug import Request as RequestBase, Response as ResponseBase, \
<mask> LocalStack, LocalProxy, cr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b5015010bc8c2a2d56c7c50b37e5b9facdad102 | flask.py | |
def __enter__(self):
_request_ctx_stack.push(self)
def __exit__(self, exc_type, exc_value, tb):
# do not pop the request stack if we are in debug mode and an
# exception happened. This will allow the debugger to still
# access the request object in the interactive shell.
... | <mask> self.g = _RequestGlobals()
<mask> self.flashes = None
<mask>
<mask>
<mask> def url_for(endpoint, **values):
<mask> """Generates a URL to the given endpoint with the method provided.
<mask>
</s> Preserve the request context in debug mode.
This makes it possible to access request in... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b5015010bc8c2a2d56c7c50b37e5b9facdad102 | flask.py |
<mask> response = self.make_response(rv)
<mask> response = self.process_response(response)
<mask> return response(environ, start_response)
<mask>
<mask> @contextmanager
<mask> def request_context(self, environ):
<mask> """Creates a request context from the giv... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b5015010bc8c2a2d56c7c50b37e5b9facdad102 | flask.py | |
return _RequestContext(self, environ) | <mask> do_something_with(request)
<mask>
<mask> :params environ: a WSGI environment
<mask> """
<mask> _request_ctx_stack.push(_RequestContext(self, environ))
<mask> try:
<mask> yield
<mask> finally:
<mask> _request_ctx_stack.pop()... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b5015010bc8c2a2d56c7c50b37e5b9facdad102 | flask.py |
Instantiating the configuration object allows you to use ``@property`` in | <mask> from werkzeug.utils import import_string
<mask> cfg = import_string('configmodule.ProductionConfig')()
<mask> app.config.from_object(cfg)
<mask>
<mask> Instantiating the configutation object allows you to use ``@property`` in
<mask> your configuration classes::
<mask>
<mask> class Confi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b88b357473226b6c25d866a2e411349b807e385 | docs/config.rst |
an extension called "Flask-Foo" might be used like this:: | <mask> Consult each extension's documentation for installation, configuration,
<mask> and usage instructions. Generally, extensions pull their own
<mask> configuration from :attr:`app.config <flask.Flask.config>` and are
<mask> passed an application instance during initialization. For example,
<mask> an extension ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b88b357473226b6c25d866a2e411349b807e385 | docs/extensions.rst |
extension for Flask does. Flask-Caching supports various backends, and it is | <mask> you actually put the result of that calculation into a cache for some
<mask> time.
<mask>
<mask> Flask itself does not provide caching for you, but `Flask-Caching`_, an
<mask> extentions for Flask does. Flask-Caching supports various backends, and it is
<mask> even possible to develop your own caching bac... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7b88b357473226b6c25d866a2e411349b807e385 | docs/patterns/caching.rst |
Version 1.1.x
-------------
Not yet released.
- Officially support passing a :class:`pathlib.Path` for
``static_folder`` which stopped working in 1.1.2. :pr:`3579`
| <mask> argument can be passed. :issue:`3553`
<mask>
<mask>
<mask> Version 1.1.2
<mask> -------------
<mask>
<mask> Released 2020-04-03
<mask>
<mask> - Work around an issue when running the ``flask`` command with an
</s> Restore support for using pathlib.Path for static_folder.
* No longer causes At... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ba35c4d4fe99418cee9c87900bd0d3b38cf5bd0 | CHANGES.rst |
value = os.fspath(value).rstrip(r"\/") | <mask>
<mask> @static_folder.setter
<mask> def static_folder(self, value):
<mask> if value is not None:
<mask> value = value.rstrip("/\\")
<mask> self._static_folder = value
<mask>
<mask> @property
<mask> def static_url_path(self):
<mask> """The URL prefix... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ba35c4d4fe99418cee9c87900bd0d3b38cf5bd0 | src/flask/helpers.py |
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")
def test_static_folder_with_pathlib_path(app):
from pathlib import Path
app = flask.Flask(__name__, static_folder=Path("static"))
rv = app.test_client().open("/static/index.html", method="GET")
assert rv.status_code == 200
... | <mask> assert rv.status_code == 200
<mask> rv.close()
<mask>
<mask>
<mask> def test_static_folder_with_ending_slash():
<mask> app = flask.Flask(__name__, static_folder="static/")
<mask>
<mask> @app.route("/<path:path>")
</s> Restore support for using pathlib.Path for static_folder.
* No lon... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7ba35c4d4fe99418cee9c87900bd0d3b38cf5bd0 | tests/test_basic.py |
- Allow returning a dictionary from a view function. Similar to how
returning a string will produce a ``text/html`` response, returning
a dict will call ``jsonify`` to produce a ``application/json``
response. :pr:`3111` | <mask> specify extra files that will trigger the reloader on change.
<mask> :issue:`2897`
<mask>
<mask> .. _#2935: https://github.com/pallets/flask/issues/2935
<mask> .. _#2957: https://github.com/pallets/flask/issues/2957
<mask> .. _#2994: https://github.com/pallets/flask/pull/2994
<mask> .. _#3059: ht... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7bf8366970ec49b5396a1f86f00fdd1c5fef3fed | CHANGES.rst |
The return value from a view function is automatically converted into
a response object for you. If the return value is a string it's
converted into a response object with the string as response body, a
``200 OK`` status code and a :mimetype:`text/html` mimetype. If the
return value is a dict, ``jsonify`` is called to ... | <mask>
<mask> About Responses
<mask> ---------------
<mask>
<mask> The return value from a view function is automatically converted into a
<mask> response object for you. If the return value is a string it's converted
<mask> into a response object with the string as response body, a ``200 OK``
<mask> status ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7bf8366970ec49b5396a1f86f00fdd1c5fef3fed | docs/quickstart.rst |
2. If it's a string, a response object is created with that data and
the default parameters.
3. If it's a dict, a response object is created using ``jsonify``.
4. If a tuple is returned the items in the tuple can provide extra
information. Such tuples have to be in the form
``(response, status)``, ``(res... | <mask> response objects is as follows:
<mask>
<mask> 1. If a response object of the correct type is returned it's directly
<mask> returned from the view.
<mask> 2. If it's a string, a response object is created with that data and the
<mask> default parameters.
<mask> 3. If a tuple is returned the ite... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7bf8366970ec49b5396a1f86f00fdd1c5fef3fed | docs/quickstart.rst |
from .json import jsonify | <mask> locked_cached_property,
<mask> url_for,
<mask> get_load_dotenv,
<mask> )
<mask> from .logging import create_logger
<mask> from .sessions import SecureCookieSessionInterface
<mask> from .signals import (
<mask> appcontext_tearing_down,
<mask> got_request_exception,
<mask> request... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7bf8366970ec49b5396a1f86f00fdd1c5fef3fed | flask/app.py |
``dict``
A dictionary that will be jsonify'd before being returned.
| <mask>
<mask> ``bytes`` (``str`` in Python 2)
<mask> A response object is created with the bytes as the body.
<mask>
<mask> ``tuple``
<mask> Either ``(body, status, headers)``, ``(body, status)``, or
<mask> ``(body, headers)``, where ``bod... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/7bf8366970ec49b5396a1f86f00fdd1c5fef3fed | flask/app.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.