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 |
|---|---|---|---|---|
<mask> from flask.json import jsonify
<mask> from flask.testing import EnvironBuilder
<mask> from flask.testing import FlaskCliRunner
<mask>
<mask> try:
<mask> import blinker
<mask> except ImportError:
<mask> blinker = None
<mask>
<mask>
<mask> def test_environ_defaults_from_config(app, client):
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9cb1a7a52d7927071e2b737d52f902f006969e82 | tests/test_testing.py | |
<mask> assert rv.is_json
<mask> assert rv.get_json() == json_data
<mask>
<mask>
<mask> @pytest.mark.skipif(blinker is None, reason="blinker is not installed")
<mask> def test_client_json_no_app_context(app, client):
<mask> @app.route("/hello", methods=["POST"])
<mask> def hello():
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9cb1a7a52d7927071e2b737d52f902f006969e82 | tests/test_testing.py | |
- Correctly invoke response handlers for both regular request dispatching as
well as error handlers. | <mask> - Make ``flask.safe_join`` able to join multiple paths like ``os.path.join``
<mask> (pull request ``#1730``).
<mask> - Revert a behavior change that made the dev server crash instead of returning
<mask> a Internal Server Error (pull request ``#2006``).
<mask>
<mask> Version 0.11.2
<mask> ------------... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9cd32cac32433d7ea03cbd64de6ab5c8ea64a981 | CHANGES |
return self.finalize_request(handler(e), from_error_handler=True) | <mask>
<mask> self.log_exception((exc_type, exc_value, tb))
<mask> if handler is None:
<mask> return InternalServerError()
<mask> return handler(e)
<mask>
<mask> def log_exception(self, exc_info):
<mask> """Logs an exception. This is called by :meth:`handle_exc... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9cd32cac32433d7ea03cbd64de6ab5c8ea64a981 | flask/app.py |
return self.finalize_request(rv)
def finalize_request(self, rv, from_error_handler=False):
"""Given the return value from a view function this finalizes
the request by converting it into a repsonse and invoking the
postprocessing functions. This is invoked for both normal
r... | <mask> if rv is None:
<mask> rv = self.dispatch_request()
<mask> except Exception as e:
<mask> rv = self.handle_user_exception(e)
<mask> response = self.make_response(rv)
<mask> try:
<mask> response = self.process_response(response)
<ma... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9cd32cac32433d7ea03cbd64de6ab5c8ea64a981 | flask/app.py |
try:
response = self.process_response(response)
request_finished.send(self, response=response)
except Exception:
if not from_error_handler:
raise
self.logger.exception('Request finalizing failed with an '
'... | <mask> rv = self.dispatch_request()
<mask> except Exception as e:
<mask> rv = self.handle_user_exception(e)
<mask> response = self.make_response(rv)
<mask> response = self.process_response(response)
<mask> request_finished.send(self, response=response)
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9cd32cac32433d7ea03cbd64de6ab5c8ea64a981 | flask/app.py |
response = self.handle_exception(e) | <mask> try:
<mask> response = self.full_dispatch_request()
<mask> except Exception as e:
<mask> error = e
<mask> response = self.make_response(self.handle_exception(e))
<mask> return response(environ, start_response)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9cd32cac32433d7ea03cbd64de6ab5c8ea64a981 | flask/app.py |
html_use_modindex = False | <mask> # template names.
<mask> #html_additional_pages = {}
<mask>
<mask> # If false, no module index is generated.
<mask> #html_use_modindex = True
<mask>
<mask> # If false, no index is generated.
<mask> #html_use_index = True
<mask>
<mask> # If true, the index is split into individual pages for each lett... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9d19b77acf413de77b39ed1c6d972fb1e5fef1c3 | docs/conf.py |
html_show_sphinx = False | <mask> # If true, links to the reST sources are added to the pages.
<mask> #html_show_sourcelink = True
<mask>
<mask> # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
<mask> #html_show_sphinx = True
<mask>
<mask> # If true, "(C) Copyright ..." is shown in the HTML footer. Default... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9d19b77acf413de77b39ed1c6d972fb1e5fef1c3 | docs/conf.py |
Continue with :ref:`tutorial-schema`.
| <mask> `templates` folder Flask will look for `Jinja2`_ templates. Drop all the
<mask> templates there.
<mask>
<mask> .. _Jinja2: http://jinja.pocoo.org/2/
</s> Added lazyloading pattern and explicit chapter links in tutorial.
This fixes #49. </s> remove #html_show_sphinx = True
</s> add html_show_sphinx = Fal... | [
"keep",
"keep",
"add",
"keep"
] | https://github.com/pallets/flask/commit/9d19b77acf413de77b39ed1c6d972fb1e5fef1c3 | docs/tutorial/folders.rst |
Continue with :ref:`tutorial-folders`.
| <mask> :align: center
<mask> :class: screenshot
<mask> :alt: screenshot of the final application
<mask>
<mask> .. _SQLAlchemy: http://www.sqlalchemy.org/
</s> Added lazyloading pattern and explicit chapter links in tutorial.
This fixes #49. </s> remove #html_show_sphinx = True
</s> add html_show_sphin... | [
"keep",
"keep",
"keep",
"add",
"keep"
] | https://github.com/pallets/flask/commit/9d19b77acf413de77b39ed1c6d972fb1e5fef1c3 | docs/tutorial/introduction.rst |
Continue with :ref:`tutorial-dbinit`. | <mask>
<mask> Want your server to be publically available? Check out the
<mask> :ref:`externally visible server <public-server>` section for more
<mask> information.
</s> Added lazyloading pattern and explicit chapter links in tutorial.
This fixes #49. </s> remove #html_show_sphinx = True
</s> add htm... | [
"keep",
"keep",
"keep",
"add"
] | https://github.com/pallets/flask/commit/9d19b77acf413de77b39ed1c6d972fb1e5fef1c3 | docs/tutorial/setup.rst |
Continue with :ref:`tutorial-templates`. | <mask> def logout():
<mask> session.pop('logged_in', None)
<mask> flash('You were logged out')
<mask> return redirect(url_for('show_entries'))
</s> Added lazyloading pattern and explicit chapter links in tutorial.
This fixes #49. </s> remove #html_show_sphinx = True
</s> add html_show... | [
"keep",
"keep",
"keep",
"add"
] | https://github.com/pallets/flask/commit/9d19b77acf413de77b39ed1c6d972fb1e5fef1c3 | docs/tutorial/views.rst |
broken_just_for_djangocon | <mask> followed = query_db('''select 1 from follower where
<mask> follower.who_id = ? and follower.whom_id = ?''',
<mask> [session['user_id'], profile_user['user_id']],
<mask> one=True) is not None
<mask> return render_template('timeline.html', messages=query_db('''
... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9d19b77acf413de77b39ed1c6d972fb1e5fef1c3 | examples/minitwit/minitwit.py |
<mask> #
<mask> # All configuration values have a default; values that are commented out
<mask> # serve to show the default.
<mask> from __future__ import print_function
<mask> from datetime import datetime
<mask> import os
<mask> import sys
<mask> import pkg_resources
<mask>
<mask> # If extensions (or modul... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9dcfd05d295574488bd0c3644599d1e97dcca3da | docs/conf.py | |
import time
import datetime
BUILD_DATE = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) | <mask> import os
<mask> import sys
<mask> import pkg_resources
<mask>
<mask> # If extensions (or modules to document with autodoc) are in another directory,
<mask> # add these directories to sys.path here. If the directory is relative to the
<mask> # documentation root, use os.path.abspath to make it absolute, ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9dcfd05d295574488bd0c3644599d1e97dcca3da | docs/conf.py |
copyright = u'2010 - {0}, Armin Ronacher'.format(BUILD_DATE.year) | <mask> master_doc = 'index'
<mask>
<mask> # General information about the project.
<mask> project = u'Flask'
<mask> copyright = u'2010 - {0}, Armin Ronacher'.format(datetime.utcnow().year)
<mask>
<mask> # The version info for the project you're documenting, acts as replacement for
<mask> # |version| and |rele... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9dcfd05d295574488bd0c3644599d1e97dcca3da | docs/conf.py |
<mask> include CHANGES.rst
<mask> include CONTRIBUTING.rst
<mask> include LICENSE.rst
<mask> include tox.ini
<mask> include requirements/*.txt
<mask> graft artwork
<mask> graft docs
<mask> prune docs/_build
</s> docs rename changelog to changes </s> remove Source License
--------------
</s> add BSD-3-Clause S... | [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9e7d3a6b694b27f997266889ae463e06dd83a189 | MANIFEST.in | |
<mask> design
<mask> htmlfaq
<mask> security
<mask> extensiondev
<mask> changelog
<mask> license
<mask> contributing
</s> docs rename changelog to changes </s> remove Source License
--------------
</s> add BSD-3-Clause Source License
--------------------------- </s> remove include LICENSE.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/9e7d3a6b694b27f997266889ae463e06dd83a189 | docs/index.rst | |
BSD-3-Clause Source License
--------------------------- | <mask> License
<mask> =======
<mask>
<mask> Source License
<mask> --------------
<mask>
<mask> The BSD-3-Clause license applies to all files in the Flask repository
<mask> and source distribution. This includes Flask's source code, the
<mask> examples, and tests, as well as the documentation.
<mask>
</s> ... | [
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9e7d3a6b694b27f997266889ae463e06dd83a189 | docs/license.rst |
from threading import Lock, Thread | <mask> """
<mask>
<mask> import os
<mask> import sys
<mask> from threading import Lock
<mask> from functools import update_wrapper
<mask>
<mask> import click
<mask>
<mask> from ._compat import iteritems
</s> Added support for background loading of the application to speed up initial requests in dev mode. ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9eb59b0bef176aa227edc8970d4b2ac420af9293 | flask/cli.py |
is imported by name in a background thread. If an error happens
it is is recorded and shows as part of the WSGI handling which in case
of the Werkzeug debugger means that it shows up in the browser. | <mask>
<mask>
<mask> class DispatchingApp(object):
<mask> """Special application that dispatches to a flask application which
<mask> is imported by name on first request. This is safer than importing
<mask> the application upfront because it means that we can forward all
<mask> errors for impo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9eb59b0bef176aa227edc8970d4b2ac420af9293 | flask/cli.py |
self._bg_loading_exc_info = None | <mask> self.loader = loader
<mask> self._app = None
<mask> self._lock = Lock()
<mask> if use_eager_loading:
<mask> self._load_unlocked()
<mask> else:
<mask> self._load_in_background()
<mask>
<mask> def _load_in_background(self):
</s> Added s... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9eb59b0bef176aa227edc8970d4b2ac420af9293 | flask/cli.py |
self._bg_loading_exc_info = None | <mask>
<mask> def _load_unlocked(self):
<mask> self._app = rv = self.loader()
<mask> return rv
<mask>
<mask> def __call__(self, environ, start_response):
<mask> if self._app is not None:
<mask> return self._app(environ, start_response)
</s> Added support for backgr... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9eb59b0bef176aa227edc8970d4b2ac420af9293 | flask/cli.py |
self._flush_bg_loading_exception() | <mask> def __call__(self, environ, start_response):
<mask> if self._app is not None:
<mask> return self._app(environ, start_response)
<mask> with self._lock:
<mask> if self._app is not None:
<mask> rv = self._app
<mask> else:
<mask> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9eb59b0bef176aa227edc8970d4b2ac420af9293 | flask/cli.py |
import os
import sys | <mask> """
<mask> from __future__ import with_statement
<mask> import flask
<mask> import unittest
<mask> import tempfile
<mask>
<mask>
<mask> example_path = os.path.join(os.path.dirname(__file__), '..', 'examples')
</s> The testsuite skips JSON tests now is not available and runs the example
tests as well. ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f0b2429d638e54cb534b555c393d0770dfc1a8f | tests/flask_tests.py |
example_path = os.path.join(os.path.dirname(__file__), '..', 'examples')
sys.path.append(os.path.join(example_path, 'flaskr'))
sys.path.append(os.path.join(example_path, 'minitwit'))
| <mask> import tempfile
<mask>
<mask>
<mask> class ContextTestCase(unittest.TestCase):
<mask>
<mask> def test_context_binding(self):
<mask> app = flask.Flask(__name__)
<mask> @app.route('/')
<mask> def index():
</s> The testsuite skips JSON tests now is not available and runs the... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f0b2429d638e54cb534b555c393d0770dfc1a8f | tests/flask_tests.py |
def suite():
from minitwit_tests import MiniTwitTestCase
from flaskr_tests import FlaskrTestCase
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ContextTestCase))
suite.addTest(unittest.makeSuite(BasicFunctionalityTestCase))
suite.addTest(unittest.makeSuite(TemplatingTestCase))
... | <mask> assert macro('World') == 'Hello World!'
<mask>
<mask>
<mask> if __name__ == '__main__':
<mask> unittest.main(defaultTest='suite')
</s> The testsuite skips JSON tests now is not available and runs the example
tests as well. </s> remove unittest.main()
</s> add unittest.main(defaul... | [
"keep",
"keep",
"add",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f0b2429d638e54cb534b555c393d0770dfc1a8f | tests/flask_tests.py |
unittest.main(defaultTest='suite') | <mask> assert macro('World') == 'Hello World!'
<mask>
<mask>
<mask> if __name__ == '__main__':
<mask> unittest.main()
</s> The testsuite skips JSON tests now is not available and runs the example
tests as well. | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/pallets/flask/commit/9f0b2429d638e54cb534b555c393d0770dfc1a8f | tests/flask_tests.py |
- The CLI loader handles ``**kwargs`` in a ``create_app`` function.
:issue:`4170` | <mask> - Correctly handle raising deferred errors in CLI lazy loading.
<mask> :issue:`4096`
<mask>
<mask>
<mask> Version 2.0.1
<mask> -------------
<mask>
<mask> Released 2021-05-21
</s> cli loader handles kwargs in app factory </s> remove if (
not args
and len(sig.parameters) == 1... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f0da9b770abfe3376ca0bbb09c535b42071feeb | CHANGES.rst |
if not args and len(sig.parameters) == 1:
first_parameter = next(iter(sig.parameters.values()))
if (
first_parameter.default is inspect.Parameter.empty
# **kwargs is reported as an empty default, ignore it
and first_parameter.kind is not inspect.Parameter.VAR_KEY... | <mask> DeprecationWarning,
<mask> )
<mask> kwargs["script_info"] = script_info
<mask>
<mask> if (
<mask> not args
<mask> and len(sig.parameters) == 1
<mask> and next(iter(sig.parameters.values())).default is inspect.Parameter.empty
<mask> ):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f0da9b770abfe3376ca0bbb09c535b42071feeb | src/flask/cli.py |
class Module:
@staticmethod
def create_app(**kwargs):
return Flask("appname")
app = find_best_app(script_info, Module)
assert isinstance(app, Flask)
assert app.name == "appname"
| <mask> assert isinstance(app, Flask)
<mask> assert app.name == "appname"
<mask>
<mask> class Module:
<mask> @staticmethod
<mask> def create_app(foo):
<mask> return Flask("appname")
<mask>
</s> cli loader handles kwargs in app factory </s> remove if (
not ar... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f0da9b770abfe3376ca0bbb09c535b42071feeb | tests/test_cli.py |
from werkzeug.exceptions import BadRequest, NotFound | <mask> except ImportError:
<mask> from urlparse import quote as url_quote
<mask>
<mask> from werkzeug.datastructures import Headers
<mask> from werkzeug.exceptions import NotFound
<mask>
<mask> # this was moved in 0.7
<mask> try:
<mask> from werkzeug.wsgi import wrap_file
<mask> except ImportError:
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f1be8e795ace494018689c87d8a5e5601313e4d | flask/helpers.py |
try:
if not os.path.isfile(filename):
raise NotFound()
except (TypeError, ValueError):
raise BadRequest() | <mask> """
<mask> filename = safe_join(directory, filename)
<mask> if not os.path.isabs(filename):
<mask> filename = os.path.join(current_app.root_path, filename)
<mask> if not os.path.isfile(filename):
<mask> raise NotFound()
<mask> options.setdefault('conditional', True)
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f1be8e795ace494018689c87d8a5e5601313e4d | flask/helpers.py |
from werkzeug.exceptions import BadRequest | <mask> import datetime
<mask> import flask
<mask> from logging import StreamHandler
<mask> from werkzeug.http import parse_cache_control_header, parse_options_header
<mask> from werkzeug.http import http_date
<mask> from flask._compat import StringIO, text_type
<mask>
</s> Raise BadRequest if static file name ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f1be8e795ace494018689c87d8a5e5601313e4d | tests/test_helpers.py |
def test_send_from_directory_bad_request(self):
app = flask.Flask(__name__)
app.testing = True
app.root_path = os.path.join(os.path.dirname(__file__),
'test_apps', 'subdomaintestmodule')
with app.test_request_context():
with pytest.rai... | <mask> assert rv.data.strip() == b'Hello Subdomain'
<mask> rv.close()
<mask>
<mask>
<mask> class TestLogging(object):
<mask>
<mask> def test_logger_cache(self):
<mask> app = flask.Flask(__name__)
</s> Raise BadRequest if static file name is invalid
* Raise BadRequest if ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f1be8e795ace494018689c87d8a5e5601313e4d | tests/test_helpers.py |
name and a dot, and by wrapping `view_func` in a `LazyView` as needed. :: | <mask>
<mask> You can further optimize this in terms of amount of keystrokes needed to
<mask> write this by having a function that calls into
<mask> :meth:`~flask.Flask.add_url_rule` by prefixing a string with the project
<mask> name and a dot, and by wrapping `view_func` in a `LazyView` as needed::
<mask>
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f2b3d815ec39279bfb838221580a36378a0de20 | docs/patterns/lazyloading.rst |
def url(import_name, url_rules=[], **options): | <mask> write this by having a function that calls into
<mask> :meth:`~flask.Flask.add_url_rule` by prefixing a string with the project
<mask> name and a dot, and by wrapping `view_func` in a `LazyView` as needed::
<mask>
<mask> def url(url_rule, import_name, **options):
<mask> view = LazyView('yourap... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f2b3d815ec39279bfb838221580a36378a0de20 | docs/patterns/lazyloading.rst |
for url_rule in url_rules:
app.add_url_rule(url_rule, view_func=view, **options) | <mask> name and a dot, and by wrapping `view_func` in a `LazyView` as needed::
<mask>
<mask> def url(url_rule, import_name, **options):
<mask> view = LazyView('yourapplication.' + import_name)
<mask> app.add_url_rule(url_rule, view_func=view, **options)
<mask>
<mask> url('/', 'views.ind... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f2b3d815ec39279bfb838221580a36378a0de20 | docs/patterns/lazyloading.rst |
# add a single route to the index view
url('views.index', ['/'])
# add two routes to a single function endpoint
url_rules = ['/user/','/user/<username>']
url('views.user', url_rules) | <mask> def url(url_rule, import_name, **options):
<mask> view = LazyView('yourapplication.' + import_name)
<mask> app.add_url_rule(url_rule, view_func=view, **options)
<mask>
<mask> url('/', 'views.index')
<mask> url('/user/<username>', 'views.user')
<mask>
<mask> One thing to keep... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f2b3d815ec39279bfb838221580a36378a0de20 | docs/patterns/lazyloading.rst |
end of a ``with`` body when used in a ``with`` statement. For general
information about how to use this class refer to
:class:`werkzeug.test.Client`. | <mask>
<mask> class FlaskClient(Client):
<mask> """Works like a regular Werkzeug test client but has some knowledge about
<mask> how Flask works to defer the cleanup of the request context stack to the
<mask> end of a with body when used in a with statement. For general information
<mask> about ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f4c569c83f3f00f43a8ea975821c405ab0057f0 | flask/testing.py |
"""When used in combination with a ``with`` statement this opens a | <mask> preserve_context = False
<mask>
<mask> @contextmanager
<mask> def session_transaction(self, *args, **kwargs):
<mask> """When used in combination with a with statement this opens a
<mask> session transaction. This can be used to modify the session that
<mask> the test ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f4c569c83f3f00f43a8ea975821c405ab0057f0 | flask/testing.py |
the test client uses. Once the ``with`` block is left the session is | <mask> @contextmanager
<mask> def session_transaction(self, *args, **kwargs):
<mask> """When used in combination with a with statement this opens a
<mask> session transaction. This can be used to modify the session that
<mask> the test client uses. Once the with block is left the ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f4c569c83f3f00f43a8ea975821c405ab0057f0 | flask/testing.py |
import re | <mask> :copyright: (c) 2010 by Armin Ronacher.
<mask> :license: BSD, see LICENSE for more details.
<mask> """
<mask> from __future__ import with_statement
<mask> import os
<mask> import sys
<mask>
<mask> from jinja2 import Environment, PackageLoader, FileSystemLoader
</s> Fixed XSS problem by escaping... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f6bc93e4de36fc209eb1203845e9505df1ca379 | flask.py |
# figure out if simplejson escapes slashes. This behaviour was changed
# from one version to another without reason.
if json_available:
_json_escapes_slashes = '\\/' in json.dumps('/')
| <mask> except (ImportError, AttributeError):
<mask> pkg_resources = None
<mask>
<mask>
<mask> class Request(RequestBase):
<mask> """The request object used by default in flask. Remembers the
<mask> matched endpoint and view arguments.
<mask>
<mask> It is what ends up as :class:`~flask.reque... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f6bc93e4de36fc209eb1203845e9505df1ca379 | flask.py |
rv = json.dumps(string, *args, **kwargs)
if not _json_escapes_slashes:
rv = rv.replace('/', '\\/')
return rv | <mask> def _tojson_filter(string, *args, **kwargs):
<mask> """Calls dumps for the template engine, escaping Slashes properly."""
<mask> if __debug__:
<mask> _assert_have_json()
<mask> return json.dumps(string, *args, **kwargs).replace('</', '<\\/')
<mask>
<mask>
<mask> class Flask(object):... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f6bc93e4de36fc209eb1203845e9505df1ca379 | flask.py |
rv = flask.render_template_string('{{ "<\0/script>"|tojson|safe }}')
assert rv == '"<\\u0000\\/script>"' | <mask> app = flask.Flask(__name__)
<mask> with app.test_request_context():
<mask> rv = flask.render_template_string('{{ "</script>"|tojson|safe }}')
<mask> assert rv == '"<\\/script>"'
<mask>
<mask>
<mask> class TemplatingTestCase(unittest.TestCase):
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f6bc93e4de36fc209eb1203845e9505df1ca379 | tests/flask_tests.py |
- Require Werkzeug >= 2.3.7. | <mask>
<mask> Unreleased
<mask>
<mask> - Python 3.12 compatibility.
<mask> - Require Werkzeug >= 2.3.6.
<mask> - Use ``flit_core`` instead of ``setuptools`` as build backend.
<mask> - Refactor how an app's root and instance paths are determined. :issue:`5160`
<mask>
<mask>
<mask> Version 2.3.2
</... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | CHANGES.rst |
"Werkzeug>=2.3.7", | <mask> "Topic :: Software Development :: Libraries :: Application Frameworks",
<mask> ]
<mask> requires-python = ">=3.8"
<mask> dependencies = [
<mask> "Werkzeug>=2.3.6",
<mask> "Jinja2>=3.1.2",
<mask> "itsdangerous>=2.1.2",
<mask> "click>=8.1.3",
<mask> "blinker>=1.6.2",
<mask> "i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | pyproject.toml |
Werkzeug==2.3.7 | <mask> Werkzeug==2.3.6
<mask> Jinja2==3.1.2
<mask> MarkupSafe==2.1.1
<mask> itsdangerous==2.1.2
<mask> click==8.1.3
<mask> blinker==1.6.2
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove client.environ_base["REMOTE_ADDR"] = "0.0.0.1"
client.environ_base["HTTP_USER_AGENT"] = "Bar"
... | [
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | requirements/tests-pallets-min.in |
# SHA1:fe057f95a98251b053eec8fa27df0feb722c70e8 | <mask> # SHA1:5bd33f1c06b3fb16f7ab50e80ed309655d110713
<mask> #
<mask> # This file is autogenerated by pip-compile-multi
<mask> # To update, run:
<mask> #
<mask> # pip-compile-multi
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove werkzeug==2.3.6
</s> add werkzeug==2.3.7 </s> remove c... | [
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | requirements/tests-pallets-min.txt |
werkzeug==2.3.7 | <mask> # via
<mask> # -r requirements/tests-pallets-min.in
<mask> # jinja2
<mask> # werkzeug
<mask> werkzeug==2.3.6
<mask> # via -r requirements/tests-pallets-min.in
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove # SHA1:5bd33f1c06b3fb16f7ab50e80ed309655d110713
</s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | requirements/tests-pallets-min.txt |
import importlib.metadata | <mask> from __future__ import annotations
<mask>
<mask> import ast
<mask> import inspect
<mask> import os
<mask> import platform
<mask> import re
<mask> import sys
<mask> import traceback
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove import werkzeug
</s> add </s> remove from flas... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | src/flask/cli.py |
flask_version = importlib.metadata.version("flask")
werkzeug_version = importlib.metadata.version("werkzeug") | <mask> def get_version(ctx, param, value):
<mask> if not value or ctx.resilient_parsing:
<mask> return
<mask>
<mask> import werkzeug
<mask> from . import __version__
<mask>
<mask> click.echo(
<mask> f"Python {platform.python_version()}\n"
<mask> f"Flask {__version__}\... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | src/flask/cli.py |
f"Flask {flask_version}\n"
f"Werkzeug {werkzeug_version}", | <mask> from . import __version__
<mask>
<mask> click.echo(
<mask> f"Python {platform.python_version()}\n"
<mask> f"Flask {__version__}\n"
<mask> f"Werkzeug {werkzeug.__version__}",
<mask> color=ctx.color,
<mask> )
<mask> ctx.exit()
<mask>
<mask>
</s> bump w... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | src/flask/cli.py |
import importlib.metadata | <mask> from __future__ import annotations
<mask>
<mask> import typing as t
<mask> from contextlib import contextmanager
<mask> from contextlib import ExitStack
<mask> from copy import copy
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove import werkzeug
</s> add </s> remove from flask ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | src/flask/testing.py |
_werkzeug_version = ""
def _get_werkzeug_version() -> str:
global _werkzeug_version
if not _werkzeug_version:
_werkzeug_version = importlib.metadata.version("werkzeug")
return _werkzeug_version
| <mask> return self.app.json.dumps(obj, **kwargs)
<mask>
<mask>
<mask> class FlaskClient(Client):
<mask> """Works like a regular Werkzeug test client but has knowledge about
<mask> Flask's contexts to defer the cleanup of the request context until
<mask> the end of a ``with`` block. For gene... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | src/flask/testing.py |
"HTTP_USER_AGENT": f"Werkzeug/{_get_werkzeug_version()}", | <mask> self._new_contexts: list[t.ContextManager[t.Any]] = []
<mask> self._context_stack = ExitStack()
<mask> self.environ_base = {
<mask> "REMOTE_ADDR": "127.0.0.1",
<mask> "HTTP_USER_AGENT": f"werkzeug/{werkzeug.__version__}",
<mask> }
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | src/flask/testing.py |
<mask> locate_app("cliapp.importerrorapp", None, raise_if_not_found=False)
<mask>
<mask>
<mask> def test_get_version(test_apps, capsys):
<mask> from flask import __version__ as flask_version
<mask> from werkzeug import __version__ as werkzeug_version
<mask> from platform import python_versi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_cli.py | |
assert f"Python {platform.python_version()}" in out
assert f"Flask {importlib.metadata.version('flask')}" in out
assert f"Werkzeug {importlib.metadata.version('werkzeug')}" in out | <mask>
<mask> ctx = MockCtx()
<mask> get_version(ctx, None, "test")
<mask> out, err = capsys.readouterr()
<mask> assert f"Python {python_version()}" in out
<mask> assert f"Flask {flask_version}" in out
<mask> assert f"Werkzeug {werkzeug_version}" in out
<mask>
<mask>
<mask> def test... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_cli.py |
<mask> import click
<mask> import pytest
<mask> import werkzeug
<mask>
<mask> import flask
<mask> from flask import appcontext_popped
<mask> from flask.cli import ScriptInfo
<mask> from flask.globals import _cv_request
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove from flask import ... | [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py | |
def test_environ_base_default(app, client): | <mask> rv = client.get("/")
<mask> assert rv.data == b"http://localhost/"
<mask>
<mask>
<mask> def test_environ_base_default(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py |
flask.g.remote_addr = flask.request.remote_addr
flask.g.user_agent = flask.request.user_agent.string
return "" | <mask>
<mask> def test_environ_base_default(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> rv = client.get("/")
<mask> assert rv.data == b"1... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py |
with client:
client.get("/")
assert flask.g.remote_addr == "127.0.0.1"
assert flask.g.user_agent == (
f"Werkzeug/{importlib.metadata.version('werkzeug')}"
) | <mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> rv = client.get("/")
<mask> assert rv.data == b"127.0.0.1"
<mask> assert flask.g.user_agent == f"werkzeug/{werkzeug.__version__}"
<mask>
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py |
def test_environ_base_modified(app, client): | <mask> assert rv.data == b"127.0.0.1"
<mask> assert flask.g.user_agent == f"werkzeug/{werkzeug.__version__}"
<mask>
<mask>
<mask> def test_environ_base_modified(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Age... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py |
flask.g.remote_addr = flask.request.remote_addr
flask.g.user_agent = flask.request.user_agent.string
return "" | <mask>
<mask> def test_environ_base_modified(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.0"
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py |
client.environ_base["REMOTE_ADDR"] = "192.168.0.22" | <mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.0"
<mask> client.environ_base["HTTP_USER_AGENT"] = "Foo"
<mask> rv = client.get("/")
<mask> a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py |
<mask> return flask.request.remote_addr
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.0"
<mask> client.environ_base["HTTP_USER_AGENT"] = "Foo"
<mask> rv = client.get("/")
<mask> assert rv.data == b"0.0.0.0"
<mask> assert flask.g.user_agent == "Foo"
<mask>
<mask> cl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py | |
with client:
client.get("/")
assert flask.g.remote_addr == "192.168.0.22"
assert flask.g.user_agent == "Foo" | <mask> rv = client.get("/")
<mask> assert rv.data == b"0.0.0.0"
<mask> assert flask.g.user_agent == "Foo"
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.1"
<mask> client.environ_base["HTTP_USER_AGENT"] = "Bar"
<mask> rv = client.get("/")
<mask> assert rv.data == b"0.0.0.1... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/9f9550247a2798b9dcc28081c15e266442f4e28a | tests/test_testing.py |
def _default_template_ctx_processor():
"""Default template context processor. Injects `request`,
`session` and `g`.
"""
reqctx = _request_ctx_stack.top
return dict(
request=reqctx.request,
session=reqctx.session,
g=reqctx.g
)
| <mask>
<mask>
<mask> class Flask(object):
<mask> """The flask object implements a WSGI application and acts as the central
<mask> object. It is passed the name of the module or package of the
<mask> application. Once it is created it will act as a central registry for
<mask> the view function... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a01e8b49ca66608f0bd46134ff02deeb5724c799 | flask.py |
#: a list of functions that are called without arguments
#: to populate the template context. Each returns a dictionary
#: that the template context is updated with.
#: To register a function here, use the :meth:`context_processor`
#: decorator.
self.template_context_pro... | <mask> #: decorator.
<mask> self.request_shutdown_funcs = []
<mask> self.url_map = Map()
<mask>
<mask> if self.static_path is not None:
<mask> self.url_map.add(Rule(self.static_path + '/<filename>',
<mask> build_only=True, endpoint='s... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a01e8b49ca66608f0bd46134ff02deeb5724c799 | flask.py |
for func in self.template_context_processors:
context.update(func()) | <mask> :param context: the context as a dictionary that is updated in place
<mask> to add extra variables.
<mask> """
<mask> reqctx = _request_ctx_stack.top
<mask> context['request'] = reqctx.request
<mask> context['session'] = reqctx.session
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a01e8b49ca66608f0bd46134ff02deeb5724c799 | flask.py |
:param response: an instance of :attr:`response_class` | <mask>
<mask> :param session: the session to be saved (a
<mask> :class:`~werkzeug.contrib.securecookie.SecureCookie`
<mask> object)
<mask> :param request: an instance of :attr:`response_class`
<mask> """
<mask> if session is not Non... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a01e8b49ca66608f0bd46134ff02deeb5724c799 | flask.py |
def context_processor(self, f):
"""Registers a template context processor function."""
self.template_context_processors.append(f)
return f
| <mask> return f
<mask>
<mask> def match_request(self):
<mask> """Matches the current request against the URL map and also
<mask> stores the endpoint and view arguments on the request object
<mask> is successful, otherwise the exception is stored.
<mask> """
<mask> ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a01e8b49ca66608f0bd46134ff02deeb5724c799 | flask.py |
Configuration becomes more useful if you can store it in a separate file, ideally
located outside the actual application package. You can deploy your application, then
separately configure it for the specific deployment. | <mask>
<mask> Configuring from Python Files
<mask> -----------------------------
<mask>
<mask> Configuration becomes more useful if you can store it in a separate file,
<mask> ideally located outside the actual application package. This makes
<mask> packaging and distributing your application possible via vari... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/config.rst |
A common pattern is this:: | <mask> packaging and distributing your application possible via various package
<mask> handling tools (:doc:`/patterns/distribute`) and finally modifying the
<mask> configuration file afterwards.
<mask>
<mask> So a common pattern is this::
<mask>
<mask> app = Flask(__name__)
<mask> app.config.from_obj... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/config.rst |
- Use a tool like `fabric`_ to push code and configuration separately
to the production server(s). | <mask> easily switch between different configs without having to touch the
<mask> code at all. If you are working often on different projects you can
<mask> even create your own script for sourcing that activates a virtualenv
<mask> and exports the development configuration for you.
<mask> - Use... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/config.rst |
What does "micro" mean? | <mask> being present. You can easily use your own templating language, but an
<mask> extension could still depend on Jinja itself.
<mask>
<mask>
<mask> Micro with Dependencies
<mask> -----------------------
<mask>
<mask> Why does Flask call itself a microframework and yet it depends on two
<mask> libraries... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/design.rst |
As your codebase grows, you are free to make the design decisions appropriate
for your project. Flask will continue to provide a very simple glue layer to
the best that Python has to offer. You can implement advanced patterns in
SQLAlchemy or another database tool, introduce non-relational data persistence
as appropr... | <mask> engine in some sort. However not every application needs a SQL database.
<mask>
<mask> The idea of Flask is to build a good foundation for all applications.
<mask> Everything else is up to you or extensions.
</s> refactor or remove old docs (#4748) </s> remove This part of the documentation, which is most... | [
"keep",
"add",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/design.rst |
Flask provides configuration and conventions, with sensible defaults, to get started.
This section of the documentation explains the different parts of the Flask framework
and how they can be used, customized, and extended. Beyond Flask itself, look for
community-maintained extensions to add even more functionality. | <mask>
<mask> User's Guide
<mask> ------------
<mask>
<mask> This part of the documentation, which is mostly prose, begins with some
<mask> background information about Flask, then focuses on step-by-step
<mask> instructions for web development with Flask.
<mask>
<mask> .. toctree::
<mask> :maxdepth: 2
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/index.rst |
<mask>
<mask> .. toctree::
<mask> :maxdepth: 2
<mask>
<mask> foreword
<mask> advanced_foreword
<mask> installation
<mask> quickstart
<mask> tutorial/index
<mask> templating
<mask> testing
</s> refactor or remove old docs (#4748) </s> remove htmlfaq
security
</s> add </s> re... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/index.rst | |
security | <mask> shell
<mask> patterns/index
<mask> deploying/index
<mask> async-await
<mask>
<mask>
</s> refactor or remove old docs (#4748) </s> remove distribute
fabric
</s> add </s> remove htmlfaq
security
</s> add </s> remove Design notes, legal information and changelog are here for the... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/index.rst |
<mask>
<mask> Additional Notes
<mask> ----------------
<mask>
<mask> Design notes, legal information and changelog are here for the interested.
<mask>
<mask> .. toctree::
<mask> :maxdepth: 2
<mask>
<mask> design
<mask> htmlfaq
</s> refactor or remove old docs (#4748) </s> remove htmlfaq
s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/index.rst | |
<mask> .. toctree::
<mask> :maxdepth: 2
<mask>
<mask> design
<mask> htmlfaq
<mask> security
<mask> extensiondev
<mask> contributing
<mask> license
<mask> changes
</s> refactor or remove old docs (#4748) </s> remove Design notes, legal information and changelog are here for the intere... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/index.rst | |
<mask> packages
<mask> appfactories
<mask> appdispatch
<mask> urlprocessors
<mask> distribute
<mask> fabric
<mask> sqlite3
<mask> sqlalchemy
<mask> fileuploads
<mask> caching
<mask> viewdecorators
</s> refactor or remove old docs (#4748) </s> remove htmlfaq
security
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/patterns/index.rst | |
Templates can be used to generate any type of text file. For web applications, you'll
primarily be generating HTML pages, but you can also generate markdown, plain text for
emails, any anything else.
For a reference to HTML, CSS, and other web APIs, use the `MDN Web Docs`_.
.. _MDN Web Docs: https://developer.mozilla... | <mask> cumbersome because you have to do the HTML escaping on your own to keep
<mask> the application secure. Because of that Flask configures the `Jinja2
<mask> <https://palletsprojects.com/p/jinja/>`_ template engine for you automatically.
<mask>
<mask> To render a template you can use the :func:`~flask.render... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a0458efef6c8a5669bb6e78044a290bf560f962b | docs/quickstart.rst |
<mask> from threading import Lock
<mask> from datetime import timedelta, datetime
<mask> from itertools import chain
<mask>
<mask> from jinja2 import Environment
<mask>
<mask> from werkzeug import ImmutableDict
<mask> from werkzeug.routing import Map, Rule
<mask> from werkzeug.exceptions import HTTPException... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/app.py | |
from .templating import DispatchingJinjaLoader, Environment, \ | <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, \
<mask> _default_template_ctx_processor
<mask> from .signals ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/app.py |
#: all the attached blueprints in a directory by name. Blueprints
#: can be attached multiple times so this dictionary does not tell
#: you how often they got attached.
#:
#: .. versionadded:: 0.7
self.blueprints = {}
| <mask> #: .. versionadded:: 0.5
<mask> self.modules = {}
<mask>
<mask> #: a place where extensions can store application specific state. For
<mask> #: example this is where an extension could store database engines and
<mask> #: similar things. For backwards compatibilit... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/app.py |
rv = Environment(self, **options) | <mask> """
<mask> options = dict(self.jinja_options)
<mask> if 'autoescape' not in options:
<mask> options['autoescape'] = self.select_jinja_autoescape
<mask> rv = Environment(loader=self.create_jinja_loader(), **options)
<mask> rv.globals.update(
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/app.py |
return DispatchingJinjaLoader(self) | <mask> override just the loader and keeping the rest unchanged.
<mask>
<mask> .. versionadded:: 0.7
<mask> """
<mask> return _DispatchingJinjaLoader(self)
<mask>
<mask> def init_jinja_globals(self):
<mask> """Deprecated. Used to initialize the Jinja2 globals.
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/app.py |
.. versionchanged:: 0.7
The module system was deprecated in favor for the blueprint
system. | <mask> of this function are the same as the ones for the constructor of the
<mask> :class:`Module` class and will override the values of the module if
<mask> provided.
<mask> """
<mask> if not self.enable_modules:
<mask> raise RuntimeError('Module support was di... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/app.py |
def register_blueprint(self, blueprint, **options):
"""Registers a blueprint on the application.
.. versionadded:: 0.7
"""
if blueprint.name in self.blueprints:
assert self.blueprints[blueprint.name] is blueprint, \
'A blueprint\'s name collision ocurred ... | <mask> func(state)
<mask>
<mask> def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
<mask> """Connects a URL rule. Works exactly like the :meth:`route`
<mask> decorator. If a view_func is provided it will be registered with the
<mask> endpoint.
</s>... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/app.py |
from jinja2 import BaseLoader, Environment as BaseEnvironment, \
TemplateNotFound | <mask> :copyright: (c) 2010 by Armin Ronacher.
<mask> :license: BSD, see LICENSE for more details.
<mask> """
<mask> import posixpath
<mask> from jinja2 import BaseLoader, TemplateNotFound
<mask>
<mask> from .globals import _request_ctx_stack
<mask> from .signals import template_rendered
<mask>
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/templating.py |
class Environment(BaseEnvironment):
"""Works like a regular Jinja2 environment but has some additional
knowledge of how Flask's blueprint works so that it can prepend the
name of the blueprint to referenced templates if necessary.
"""
def __init__(self, app, **options):
if 'loader' not in o... | <mask> g=reqctx.g
<mask> )
<mask>
<mask>
<mask> class _DispatchingJinjaLoader(BaseLoader):
<mask> """A loader that looks for templates in the application and all
<mask> the module folders.
<mask> """
<mask>
<mask> def __init__(self, app):
</s> Started work on implementing bluep... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/templating.py |
# newstyle template support. blueprints are explicit and no further
# magic is involved. If the template cannot be loaded by the
# blueprint loader it just gives up, no further steps involved.
if ':' in template:
blueprint_name, local_template = template.split(':', 1)
... | <mask> def __init__(self, app):
<mask> self.app = app
<mask>
<mask> def get_source(self, environment, template):
<mask> template = posixpath.normpath(template)
<mask> if template.startswith('../'):
<mask> raise TemplateNotFound(template)
<mask> loader = None
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/templating.py |
module, name = posixpath.normpath(template).split('/', 1) | <mask> if template.startswith('../'):
<mask> raise TemplateNotFound(template)
<mask> loader = None
<mask> try:
<mask> module, name = template.split('/', 1)
<mask> loader = self.app.modules[module].jinja_loader
<mask> except (ValueError, KeyError... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/templating.py |
except (ValueError, KeyError, TemplateNotFound): | <mask> loader = None
<mask> try:
<mask> module, name = template.split('/', 1)
<mask> loader = self.app.modules[module].jinja_loader
<mask> except (ValueError, KeyError):
<mask> pass
<mask> # if there was a module and it has a loader, try this fi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/templating.py |
try:
if loader is not None: | <mask> module, name = template.split('/', 1)
<mask> loader = self.app.modules[module].jinja_loader
<mask> except (ValueError, KeyError):
<mask> pass
<mask> # if there was a module and it has a loader, try this first
<mask> if loader is not None:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/templating.py |
except TemplateNotFound:
pass
# at the very last, load templates from the environment | <mask> # if there was a module and it has a loader, try this first
<mask> if loader is not None:
<mask> try:
<mask> return loader.get_source(environment, name)
<mask> except TemplateNotFound:
<mask> pass
<mask> # fall back to applica... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239 | flask/templating.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.