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 |
|---|---|---|---|---|
if sys.version_info < (2, 7, 9): | <mask> with pytest.raises(click.BadParameter):
<mask> run_command.make_context('run', ['--cert', 'flask'])
<mask>
<mask> # SSLContext
<mask> if sys.version_info < (2, 7):
<mask> ssl_context = object()
<mask> else:
<mask> ssl_context = ssl.SSLContext(ssl.PROTOCOL_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a913b4dafd1d85cfa1d8bafeea5417748de8d487 | tests/test_cli.py |
- Fix type annotation for ``teardown_request``. :issue:`4093`
- Fix type annotation for ``before_request`` and ``before_app_request``
decorators. :issue:`4104` | <mask> -------------
<mask>
<mask> Unreleased
<mask>
<mask> - Fix type annotation for ``teardown_request``. :issue:`4093`
<mask>
<mask>
<mask> Version 2.0.1
<mask> -------------
<mask>
</s> Fix type annotation for `before_request` and `before_app_request` decorators </s> remove BeforeRequestCallable = ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a960236117442bec67f89c30dfa014e05483da5a | CHANGES.rst |
from .typing import BeforeFirstRequestCallable | <mask> from .templating import DispatchingJinjaLoader
<mask> from .templating import Environment
<mask> from .typing import AfterRequestCallable
<mask> from .typing import BeforeRequestCallable
<mask> from .typing import ErrorHandlerCallable
<mask> from .typing import ResponseReturnValue
<mask> from .typing impo... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a960236117442bec67f89c30dfa014e05483da5a | src/flask/app.py |
self.before_first_request_funcs: t.List[BeforeFirstRequestCallable] = [] | <mask> #: first request to this instance. To register a function, use the
<mask> #: :meth:`before_first_request` decorator.
<mask> #:
<mask> #: .. versionadded:: 0.8
<mask> self.before_first_request_funcs: t.List[BeforeRequestCallable] = []
<mask>
<mask> #: A list... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a960236117442bec67f89c30dfa014e05483da5a | src/flask/app.py |
def before_first_request(
self, f: BeforeFirstRequestCallable
) -> BeforeFirstRequestCallable: | <mask> """
<mask> self.jinja_env.globals[name or f.__name__] = f
<mask>
<mask> @setupmethod
<mask> def before_first_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable:
<mask> """Registers a function to be run before the first request to this
<mask> instance ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a960236117442bec67f89c30dfa014e05483da5a | src/flask/app.py |
from .typing import BeforeFirstRequestCallable | <mask> from .scaffold import _endpoint_from_view_func
<mask> from .scaffold import _sentinel
<mask> from .scaffold import Scaffold
<mask> from .typing import AfterRequestCallable
<mask> from .typing import BeforeRequestCallable
<mask> from .typing import ErrorHandlerCallable
<mask> from .typing import TeardownCa... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a960236117442bec67f89c30dfa014e05483da5a | src/flask/blueprints.py |
self, f: BeforeFirstRequestCallable
) -> BeforeFirstRequestCallable: | <mask> )
<mask> return f
<mask>
<mask> def before_app_first_request(
<mask> self, f: BeforeRequestCallable
<mask> ) -> BeforeRequestCallable:
<mask> """Like :meth:`Flask.before_first_request`. Such a function is
<mask> executed before the first request to the ap... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a960236117442bec67f89c30dfa014e05483da5a | src/flask/blueprints.py |
BeforeFirstRequestCallable = t.Callable[[], None]
BeforeRequestCallable = t.Callable[[], t.Optional[ResponseReturnValue]] | <mask> ]
<mask>
<mask> AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named
<mask> AfterRequestCallable = t.Callable[["Response"], "Response"]
<mask> BeforeRequestCallable = t.Callable[[], None]
<mask> ErrorHandlerCallable = t.Callable[[Exception], ResponseReturnValue]
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a960236117442bec67f89c30dfa014e05483da5a | src/flask/typing.py |
self.app.teardown_request(self.teardown_request) | <mask>
<mask> def __init__(self, app):
<mask> self.app = app
<mask> self.app.config.setdefault('SQLITE3_DATABASE', ':memory:')
<mask> self.app.after_request(self.after_request)
<mask> self.app.before_request(self.before_request)
<mask>
<mask> def... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/extensiondev.rst |
def teardown_request(self, exception): | <mask> def before_request(self):
<mask> ctx = _request_ctx_stack.top
<mask> ctx.sqlite3_db = self.connect()
<mask>
<mask> def after_request(self, response):
<mask> ctx = _request_ctx_stack.top
<mask> ctx.sqlite3_db.close()
<mask> retur... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/extensiondev.rst |
<mask>
<mask> def after_request(self, response):
<mask> ctx = _request_ctx_stack.top
<mask> ctx.sqlite3_db.close()
<mask> return response
<mask>
<mask> def get_db(self):
<mask> ctx = _request_ctx_stack.top
<mask> if ctx is not None:
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/extensiondev.rst | |
`teardown_request` handlers. | <mask> SQLite.
<mask> 2. We create a class for our extension that requires a supplied `app` object,
<mask> sets a configuration for the database if it's not there
<mask> (:meth:`dict.setdefault`), and attaches `before_request` and
<mask> `after_request` handlers.
<mask> 3. Next, we define a `con... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/extensiondev.rst |
self.app.teardown_request(self.teardown_request) | <mask>
<mask> def init_app(self, app):
<mask> self.app = app
<mask> self.app.config.setdefault('SQLITE3_DATABASE', ':memory:')
<mask> self.app.after_request(self.after_request)
<mask> self.app.before_request(self.before_request)
<mask>
<mask> def... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/extensiondev.rst |
def teardown_request(self, exception): | <mask> def before_request(self):
<mask> ctx = _request_ctx_stack.top
<mask> ctx.sqlite3_db = self.connect()
<mask>
<mask> def after_request(self, response):
<mask> ctx = _request_ctx_stack.top
<mask> ctx.sqlite3_db.close()
<mask> retur... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/extensiondev.rst |
<mask>
<mask> def after_request(self, response):
<mask> ctx = _request_ctx_stack.top
<mask> ctx.sqlite3_db.close()
<mask> return response
<mask>
<mask> def get_db(self):
<mask> ctx = _request_ctx_stack.top
<mask> if ctx is not None:
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/extensiondev.rst | |
@app.teardown_request
def shutdown_session(exception=None): | <mask> automatically remove database sessions at the end of the request for you::
<mask>
<mask> from yourapplication.database import db_session
<mask>
<mask> @app.after_request
<mask> def shutdown_session(response):
<mask> db_session.remove()
<mask> return response
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/patterns/sqlalchemy.rst |
<mask>
<mask> @app.after_request
<mask> def shutdown_session(response):
<mask> db_session.remove()
<mask> return response
<mask>
<mask> Here is an example model (put this into `models.py`, e.g.)::
<mask>
<mask> from sqlalchemy import Column, Integer, String
<mask> from youra... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/patterns/sqlalchemy.rst | |
@app.teardown_request
def shutdown_session(exception=None): | <mask> each request. Put this into your application module::
<mask>
<mask> from yourapplication.database import db_session
<mask>
<mask> @app.after_request
<mask> def shutdown_session(response):
<mask> db_session.remove()
<mask> return response
<mask>
<mask> Here is an example ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/patterns/sqlalchemy.rst |
<mask>
<mask> @app.after_request
<mask> def shutdown_session(response):
<mask> db_session.remove()
<mask> return response
<mask>
<mask> Here is an example table and model (put this into `models.py`)::
<mask>
<mask> from sqlalchemy import Table, Column, Integer, String
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/patterns/sqlalchemy.rst | |
:meth:`~flask.Flask.before_request` and :meth:`~flask.Flask.teardown_request` | <mask> =========================
<mask>
<mask> In Flask you can implement the opening of database connections at the
<mask> beginning of the request and closing at the end with the
<mask> :meth:`~flask.Flask.before_request` and :meth:`~flask.Flask.after_request`
<mask> decorators in combination with the special ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/patterns/sqlite3.rst |
@app.teardown_request
def teardown_request(exception): | <mask> @app.before_request
<mask> def before_request():
<mask> g.db = connect_db()
<mask>
<mask> @app.after_request
<mask> def after_request(response):
<mask> g.db.close()
<mask> return response
<mask>
<mask> .. _easy-querying:
<mask>
</s> Updated documentation to ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/patterns/sqlite3.rst |
Connect on Demand
-----------------
The downside of this approach is that this will only work if Flask
executed the before-request handlers for you. If you are attempting to
use the database from a script or the interactive Python shell you would
have to do something like this::
with app.test_request_context()
... | <mask>
<mask> @app.after_request
<mask> def after_request(response):
<mask> g.db.close()
<mask> return response
<mask>
<mask> .. _easy-querying:
<mask>
<mask> Easy Querying
<mask> -------------
</s> Updated documentation to use teardown request where appropriate </s> remove @ap... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/patterns/sqlite3.rst |
:meth:`~flask.Flask.teardown_request` and :meth:`~flask.Flask.teardown_request`
decorators:: | <mask> connection in all our functions so it makes sense to initialize them
<mask> before each request and shut them down afterwards.
<mask>
<mask> Flask allows us to do that with the :meth:`~flask.Flask.before_request`,
<mask> :meth:`~flask.Flask.after_request` and :meth:`~flask.Flask.teardown_request`
<mask> d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"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/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/tutorial/dbcon.rst |
:meth:`~flask.Flask.teardown_request` are called after a request and | <mask> g.db.close()
<mask>
<mask> Functions marked with :meth:`~flask.Flask.before_request` are called before
<mask> a request and passed no arguments. Functions marked with
<mask> :meth:`~flask.Flask.after_request` are called after a request and
<mask> passed the response that will be sent to the clien... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/tutorial/dbcon.rst |
that response object or a different one. They are however not guaranteed
to be executed if an exception is raised, this is where functions marked with
:meth:`~flask.Flask.teardown_request` come in. They get called after the | <mask> Functions marked with :meth:`~flask.Flask.before_request` are called before
<mask> a request and passed no arguments. Functions marked with
<mask> :meth:`~flask.Flask.after_request` are called after a request and
<mask> passed the response that will be sent to the client. They have to return
<mask> that r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/tutorial/dbcon.rst |
being processed, it is passed to each function; otherwise, `None` is passed in. | <mask>
<mask> Functions marked with :meth:`~flask.Flask.teardown_request` get called after the
<mask> response has been constructed. They are not allowed to modify the request, and
<mask> their return values are ignored. If an exception occurred while the request was
<mask> being processed, it is passed to each... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/tutorial/dbcon.rst |
object that Flask provides for us. This object stores information for one | <mask> their return values are ignored. If an exception occurred while the request was
<mask> being processed, it is passed to each function; otherwise, None is passed in.
<mask>
<mask> We store our current database connection on the special :data:`~flask.g`
<mask> object that flask provides for us. This object... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a9fc040c39109f86f3ea98440215b4a54f291f53 | docs/tutorial/dbcon.rst |
- When using lazy loading (the default with the debugger), the Click
context from the ``flask run`` command remains available in the
loader thread. :issue:`4460` | <mask> command to specify patterns that will be ignored by the reloader.
<mask> :issue:`4188`
<mask>
<mask>
<mask> Version 2.0.3
<mask> -------------
<mask>
</s> lazy loading preserves click context | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa13521d42bfdb66bb0d89005cbe54a84eaa4fda | CHANGES.rst |
# Store the Click context and push it in the loader thread so
# script_info is still available.
ctx = click.get_current_context(silent=True)
| <mask> self._load_in_background()
<mask>
<mask> def _load_in_background(self):
<mask> def _load_app():
<mask> __traceback_hide__ = True # noqa: F841
<mask>
<mask> with self._lock:
</s> lazy loading preserves click context | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa13521d42bfdb66bb0d89005cbe54a84eaa4fda | src/flask/cli.py |
if ctx is not None:
click.globals.push_context(ctx)
| <mask> __traceback_hide__ = True # noqa: F841
<mask>
<mask> with self._lock:
<mask> try:
<mask> self._load_unlocked()
<mask> except Exception as e:
<mask> self._bg_loading_exc = e
</s> lazy loading preserves click ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa13521d42bfdb66bb0d89005cbe54a84eaa4fda | src/flask/cli.py |
- the :attr:`~flask.Flask.config` is now available in the templates
as `config`.
- context processors will no longer override values passed directly
to the render function. | <mask> remove the static folder if it's part of a mapping in the .yml
<mask> file.
<mask>
<mask> Version 0.5.1
<mask> -------------
<mask>
<mask> Bugfix Release, released on July 6th 2010
<mask>
</s> Config is now available in templates, context processors no longer override keys </s> remove Thi... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa3d8398fd1a38b449b64fea4979f358f3c711e3 | CHANGES |
Another change that breaks backwards compatibility is that context
processors will no longer override values passed directly to the template
rendering function. If for example `request` is as variable passed
directly to the template, the default context processor will not override
it with the current request object. ... | <mask> change the order.
<mask>
<mask> Version 0.5
<mask> -----------
<mask>
<mask> Flask 0.5 is the first release that comes as a Python package instead of a
<mask> single module. There were a couple of internal refactoring so if you
</s> Config is now available in templates, context processors no longer ov... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa3d8398fd1a38b449b64fea4979f358f3c711e3 | docs/upgrading.rst |
This injects request, session, config and g into the template
context as well as everything template context processors want
to inject. Note that the as of Flask 0.6, the original values
in the context will not be overriden if a context processor
decides to return a value with t... | <mask> return filename.endswith(('.html', '.htm', '.xml', '.xhtml'))
<mask>
<mask> def update_template_context(self, context):
<mask> """Update the template context with some commonly used variables.
<mask> This injects request, session and g into the template context.
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa3d8398fd1a38b449b64fea4979f358f3c711e3 | flask/app.py |
orig_ctx = context.copy() | <mask> mod = _request_ctx_stack.top.request.module
<mask> if mod is not None and mod in self.template_context_processors:
<mask> funcs = chain(funcs, self.template_context_processors[mod])
<mask> for func in funcs:
<mask> context.update(func())
<mask> # make... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa3d8398fd1a38b449b64fea4979f358f3c711e3 | flask/app.py |
# make sure the original values win. This makes it possible to
# easier add new variables in context processors without breaking
# existing views.
context.update(orig_ctx) | <mask> orig_ctx = context.copy()
<mask> for func in funcs:
<mask> context.update(func())
<mask>
<mask> def run(self, host='127.0.0.1', port=5000, **options):
<mask> """Runs the application on a local development server. If the
<mask> :attr:`debug` flag is set the... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa3d8398fd1a38b449b64fea4979f358f3c711e3 | flask/app.py |
config=reqctx.app.config, | <mask> """
<mask> reqctx = _request_ctx_stack.top
<mask> return dict(
<mask> request=reqctx.request,
<mask> session=reqctx.session,
<mask> g=reqctx.g
<mask> )
<mask>
<mask>
</s> Config is now available in templates, context processors no longer override keys </s> remo... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa3d8398fd1a38b449b64fea4979f358f3c711e3 | flask/templating.py |
- Correctly handle raising deferred errors in CLI lazy loading.
:issue:`4096` | <mask> :issue:`4150`
<mask> - ``jsonify`` handles ``decimal.Decimal`` by encoding to ``str``.
<mask> :issue:`4157`
<mask>
<mask>
<mask> Version 2.0.1
<mask> -------------
<mask>
</s> correctly handle raising deferred errors in cli lazy loading </s> remove self._bg_loading_exc_info = None
... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa6dd09c2cab5eb15a45d73b5ade24b7b4131c5a | CHANGES.rst |
self._bg_loading_exc = None | <mask> def __init__(self, loader, use_eager_loading=None):
<mask> self.loader = loader
<mask> self._app = None
<mask> self._lock = Lock()
<mask> self._bg_loading_exc_info = None
<mask>
<mask> if use_eager_loading is None:
<mask> use_eager_loading = os.env... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa6dd09c2cab5eb15a45d73b5ade24b7b4131c5a | src/flask/cli.py |
except Exception as e:
self._bg_loading_exc = e | <mask> __traceback_hide__ = True # noqa: F841
<mask> with self._lock:
<mask> try:
<mask> self._load_unlocked()
<mask> except Exception:
<mask> self._bg_loading_exc_info = sys.exc_info()
<mask>
<mask> t = Th... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa6dd09c2cab5eb15a45d73b5ade24b7b4131c5a | src/flask/cli.py |
exc = self._bg_loading_exc
if exc is not None:
self._bg_loading_exc = None
raise exc | <mask> t.start()
<mask>
<mask> def _flush_bg_loading_exception(self):
<mask> __traceback_hide__ = True # noqa: F841
<mask> exc_info = self._bg_loading_exc_info
<mask> if exc_info is not None:
<mask> self._bg_loading_exc_info = None
<mask> raise exc_i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa6dd09c2cab5eb15a45d73b5ade24b7b4131c5a | src/flask/cli.py |
self._bg_loading_exc = None | <mask>
<mask> def _load_unlocked(self):
<mask> __traceback_hide__ = True # noqa: F841
<mask> self._app = rv = self.loader()
<mask> self._bg_loading_exc_info = None
<mask> return rv
<mask>
<mask> def __call__(self, environ, start_response):
<mask> __traceback_h... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa6dd09c2cab5eb15a45d73b5ade24b7b4131c5a | src/flask/cli.py |
from flask.cli import DispatchingApp | <mask> from flask import Blueprint
<mask> from flask import current_app
<mask> from flask import Flask
<mask> from flask.cli import AppGroup
<mask> from flask.cli import dotenv
<mask> from flask.cli import find_best_app
<mask> from flask.cli import FlaskGroup
<mask> from flask.cli import get_version
<mask> fro... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa6dd09c2cab5eb15a45d73b5ade24b7b4131c5a | tests/test_cli.py |
def test_load_in_background():
pytest.raises(Exception, DispatchingApp, "appname123") | <mask> if int(click.__version__[0]) < 8:
<mask> pytest.deprecated_call(cli_main, match=".* Click 7 is deprecated")
<mask> else:
<mask> cli_main()
</s> correctly handle raising deferred errors in cli lazy loading </s> remove self._bg_loading_exc_info = None
</s> add ... | [
"keep",
"keep",
"keep",
"add"
] | https://github.com/pallets/flask/commit/aa6dd09c2cab5eb15a45d73b5ade24b7b4131c5a | tests/test_cli.py |
TEMPLATE_LOOKAHEAD = 4096
| <mask> except ImportError:
<mask> ast = None
<mask>
<mask>
<mask> _from_import_re = re.compile(r'^\s*from flask import\s+')
<mask> _string_re_part = r"('([^'\\]*(?:\\.[^'\\]*)*)'" \
<mask> r'|"([^"\\]*(?:\\.[^"\\]*)*)")'
<mask> _url_for_re = re.compile(r'\b(url_for\()(%s)' % _string_re_p... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa863efd9294dcd8afef6e5fa590ae2f88cbb0a2 | scripts/flask-07-upgrade.py |
<mask> (re.compile(r'(app|application)\.modules'), '\\1.blueprints')
<mask> ]
<mask>
<mask>
<mask> def error(message):
<mask> print >> sys.stderr, 'error:', message
<mask> sys.exit(1)
<mask>
<mask>
<mask> def make_diff(filename, old, new):
<mask> for line in difflib.unified_diff(old.split... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa863efd9294dcd8afef6e5fa590ae2f88cbb0a2 | scripts/flask-07-upgrade.py | |
contents = f.read(TEMPLATE_LOOKAHEAD) | <mask> if filename.endswith('.py'):
<mask> yield filename, 'python'
<mask> else:
<mask> with open(filename) as f:
<mask> contents = f.read()
<mask> if '{% for' or '{% if' or '{{ url_for' in contents:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa863efd9294dcd8afef6e5fa590ae2f88cbb0a2 | scripts/flask-07-upgrade.py |
<mask>
<mask>
<mask> def main():
<mask> """Entrypoint"""
<mask> if ast is None:
<mask> error('Python 2.6 or later is required to run the upgrade script.\n'
<mask> 'The runtime requirements for Flask 0.7 however are still '
<mask> 'Python 2.5.')
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa863efd9294dcd8afef6e5fa590ae2f88cbb0a2 | scripts/flask-07-upgrade.py | |
if ast is None:
parser.error('Python 2.6 or later is required to run the upgrade script.\n'
'The runtime requirements for Flask 0.7 however are still '
'Python 2.5.')
| <mask> if not args:
<mask> args = ['.']
<mask>
<mask> if options.no_bundled_tmpl:
<mask> template_bundles = False
<mask> elif options.bundled_tmpl:
<mask> template_bundles = True
<mask> else:
</s> Don't scan the whole file contents for template detection </s> remove ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa863efd9294dcd8afef6e5fa590ae2f88cbb0a2 | scripts/flask-07-upgrade.py |
# build the package | <mask> # the servers where the commands are executed
<mask> env.hosts = ['server1.example.com', 'server2.example.com']
<mask>
<mask> def pack():
<mask> # create a new source distribution as tarball
<mask> local('python setup.py sdist --formats=gztar', capture=False)
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa9a994946acf45187cb12506b47433306aa3473 | docs/patterns/fabric.rst |
# figure out the package name and version | <mask> # create a new source distribution as tarball
<mask> local('python setup.py sdist --formats=gztar', capture=False)
<mask>
<mask> def deploy():
<mask> # figure out the release name and version
<mask> dist = local('python setup.py --fullname', capture=True).strip()
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa9a994946acf45187cb12506b47433306aa3473 | docs/patterns/fabric.rst |
filename = '%s.tar.gz' % dist
# upload the package to the temporary folder on the server
put('dist/%s' % filename, '/tmp/%s' % filename) | <mask>
<mask> def deploy():
<mask> # figure out the release name and version
<mask> dist = local('python setup.py --fullname', capture=True).strip()
<mask> # upload the source tarball to the temporary folder on the server
<mask> put('dist/%s.tar.gz' % dist, '/tmp/yourapplicati... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"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/aa9a994946acf45187cb12506b47433306aa3473 | docs/patterns/fabric.rst |
# install the package in the application's virtualenv with pip
run('/var/www/yourapplication/env/bin/pip install /tmp/%s' % filename) | <mask> # and finally touch the .wsgi file so that mod_wsgi triggers
<mask> # a reload of the application
<mask> run('touch /var/www/yourapplication.wsgi')
<mask>
<mask> The example above is well documented and should be straightforward. Here
<mask> a recap of the most common commands fab... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa9a994946acf45187cb12506b47433306aa3473 | docs/patterns/fabric.rst |
# remove the uploaded package
run('rm -r /tmp/%s' % filename)
# touch the .wsgi file to trigger a reload in mod_wsgi
run('touch /var/www/yourapplication.wsgi') | <mask>
<mask> The example above is well documented and should be straightforward. Here
<mask> a recap of the most common commands fabric provides:
<mask>
<mask> - `run` - executes a command on a remote server
<mask> - `local` - executes a command on the local machine
<mask> - `put` - uploads a file to t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aa9a994946acf45187cb12506b47433306aa3473 | docs/patterns/fabric.rst |
- The test client's ``as_tuple`` parameter is removed. Use
``response.request.environ`` instead. :pr:`4417` | <mask> instead.
<mask> - The same blueprint cannot be registered with the same name. Use
<mask> ``name=`` when registering to specify a unique name.
<mask>
<mask> - Some parameters in ``send_file`` and ``send_from_directory`` were
<mask> renamed in 2.0. The deprecation period for the ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aab064fee164aa9f0ee35ba3065b031655888ce5 | CHANGES.rst |
<mask> buffered: bool = False,
<mask> follow_redirects: bool = False,
<mask> **kwargs: t.Any,
<mask> ) -> "TestResponse":
<mask> as_tuple = kwargs.pop("as_tuple", None)
<mask>
<mask> # Same logic as super.open, but apply environ_base and preserve_context.
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aab064fee164aa9f0ee35ba3065b031655888ce5 | src/flask/testing.py | |
return super().open(
request,
buffered=buffered,
follow_redirects=follow_redirects,
) | <mask> request = builder.get_request()
<mask> finally:
<mask> builder.close()
<mask>
<mask> if as_tuple is not None:
<mask> import warnings
<mask>
<mask> warnings.warn(
<mask> "'as_tuple' is deprecated and will be rem... | [
"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/aab064fee164aa9f0ee35ba3065b031655888ce5 | src/flask/testing.py |
told where to find your application in order to use it. The ``--app``
option is used to specify how to load the application. | <mask> Application Discovery
<mask> ---------------------
<mask>
<mask> The ``flask`` command is installed by Flask, not your application; it must be
<mask> told where to find your application in order to use it. The ``FLASK_APP``
<mask> environment variable is used to specify how to load the application.
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
While ``--app`` supports a variety of options for specifying your | <mask> The ``flask`` command is installed by Flask, not your application; it must be
<mask> told where to find your application in order to use it. The ``FLASK_APP``
<mask> environment variable is used to specify how to load the application.
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask> ... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
``--app hello`` | <mask> The name "app" or "wsgi" is imported (as a ".py" file, or package),
<mask> automatically detecting an app (``app`` or ``application``) or
<mask> factory (``create_app`` or ``make_app``).
<mask>
<mask> ``FLASK_APP=hello``
<mask> The given name is imported, automatically detecting an app (``... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
``--app`` has three parts: an optional path that sets the current working | <mask> or ``application``) or factory (``create_app`` or ``make_app``).
<mask>
<mask> ----
<mask>
<mask> ``FLASK_APP`` has three parts: an optional path that sets the current working
<mask> directory, a Python file or dotted import path, and an optional variable
<mask> name of the instance or factory. If t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
``--app src/hello`` | <mask> name of the instance or factory. If the name is a factory, it can optionally
<mask> be followed by arguments in parentheses. The following values demonstrate these
<mask> parts:
<mask>
<mask> ``FLASK_APP=src/hello``
<mask> Sets the current working directory to ``src`` then imports ``hello``.
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
``--app hello.web`` | <mask>
<mask> ``FLASK_APP=src/hello``
<mask> Sets the current working directory to ``src`` then imports ``hello``.
<mask>
<mask> ``FLASK_APP=hello.web``
<mask> Imports the path ``hello.web``.
<mask>
<mask> ``FLASK_APP=hello:app2``
<mask> Uses the ``app2`` Flask instance in ``hello``.
<mask>
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
``--app hello:app2`` | <mask>
<mask> ``FLASK_APP=hello.web``
<mask> Imports the path ``hello.web``.
<mask>
<mask> ``FLASK_APP=hello:app2``
<mask> Uses the ``app2`` Flask instance in ``hello``.
<mask>
<mask> ``FLASK_APP="hello:create_app('dev')"``
<mask> The ``create_app`` factory in ``hello`` is called with the string... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
``--app 'hello:create_app("dev")'`` | <mask>
<mask> ``FLASK_APP=hello:app2``
<mask> Uses the ``app2`` Flask instance in ``hello``.
<mask>
<mask> ``FLASK_APP="hello:create_app('dev')"``
<mask> The ``create_app`` factory in ``hello`` is called with the string ``'dev'``
<mask> as the argument.
<mask>
<mask> If ``FLASK_APP`` is not set,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
If ``--app`` is not set, the command will try to import "app" or | <mask> ``FLASK_APP="hello:create_app('dev')"``
<mask> The ``create_app`` factory in ``hello`` is called with the string ``'dev'``
<mask> as the argument.
<mask>
<mask> If ``FLASK_APP`` is not set, the command will try to import "app" or
<mask> "wsgi" (as a ".py" file, or package) and try to detect an app... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
The environment in which the Flask app executes is set by the
``FLASK_ENV`` environment variable. When using the ``flask`` command, it
can also be set with the ``--env`` option. If not set it defaults to | <mask> ------------
<mask>
<mask> .. versionadded:: 1.0
<mask>
<mask> The environment in which the Flask app runs is set by the
<mask> :envvar:`FLASK_ENV` environment variable. If not set it defaults to
<mask> ``production``. The other recognized environment is ``development``.
<mask> Flask and extensions may... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
.. code-block:: text | <mask> If the env is set to ``development``, the ``flask`` command will enable
<mask> debug mode and ``flask run`` will enable the interactive debugger and
<mask> reloader.
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ expor... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
$ flask --app hello --env development run
* Serving Flask app "hello"
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with inotify reloader
* Debugger is active!
* Debugger PIN: 223-456-919 | <mask> .. group-tab:: Powershell
<mask>
<mask> .. code-block:: text
<mask>
<mask> > $env:FLASK_ENV = "development"
<mask> > flask run
<mask> * Serving Flask app "hello"
<mask> * Environment: development
<mask> * Debug mode: on
<mask> * Runni... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
additional files with the ``--extra-files`` option. Multiple paths are | <mask> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<mask>
<mask> When using development mode, the reloader will trigger whenever your
<mask> Python code or imported modules change. The reloader can watch
<mask> additional files with the ``--extra-files`` option, or the
<mask> ``FLASK_RUN_EXTRA_FILES`` environment variab... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
.. code-block:: text | <mask> additional files with the ``--extra-files`` option, or the
<mask> ``FLASK_RUN_EXTRA_FILES`` environment variable. Multiple paths are
<mask> separated with ``:``, or ``;`` on Windows.
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask>... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
$ flask run --extra-files file1:dirA/file2:dirB/
* Running on http://127.0.0.1:8000/
* Detected change in '/path/to/file1', reloading | <mask> .. group-tab:: Powershell
<mask>
<mask> .. code-block:: text
<mask>
<mask> > flask run --extra-files file1:dirA/file2:dirB/
<mask> # or
<mask> > $env:FLASK_RUN_EXTRA_FILES = "file1:dirA/file2:dirB/"
<mask> > flask run
<mask> * Running on http... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
the ``--exclude-patterns`` option. Multiple patterns are separated with
``:``, or ``;`` on Windows. | <mask> Ignore files with the Reloader
<mask> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<mask>
<mask> The reloader can also ignore files using :mod:`fnmatch` patterns with
<mask> the ``--exclude-patterns`` option, or the ``FLASK_RUN_EXCLUDE_PATTERNS``
<mask> environment variable. Multiple patterns are separated with ``:``, ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
Debug mode will be enabled when the execution environment is
``development``, as described above. If you want to control debug mode
separately, use the ``--debug/--no-debug`` option or the ``FLASK_DEBUG``
environment variable. | <mask>
<mask> Debug Mode
<mask> ----------
<mask>
<mask> Debug mode will be enabled when :envvar:`FLASK_ENV` is ``development``,
<mask> as described above. If you want to control debug mode separately, use
<mask> :envvar:`FLASK_DEBUG`. The value ``1`` enables it, ``0`` disables it.
<mask>
<mask>
<mask> ..... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
The ``flask`` command supports setting any option for any command with
environment variables. The variables are named like ``FLASK_OPTION`` or
``FLASK_COMMAND_OPTION``, for example ``FLASK_APP`` or
``FLASK_RUN_PORT``.
Rather than passing options every time you run a command, or environment
variables every time you ope... | <mask>
<mask> Environment Variables From dotenv
<mask> ---------------------------------
<mask>
<mask> Rather than setting ``FLASK_APP`` each time you open a new terminal, you can
<mask> use Flask's dotenv support to set environment variables automatically.
<mask>
<mask> If `python-dotenv`_ is installed, run... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
environment variables defined in the files ``.env`` and ``.flaskenv``.
You can also specify an extra file to load with the ``--env-file``
option. Dotenv files can be used to avoid having to set ``--app`` or
``FLASK_APP`` manually, and to set configuration using environment
variables similar to how some deployment servi... | <mask> Rather than setting ``FLASK_APP`` each time you open a new terminal, you can
<mask> use Flask's dotenv support to set environment variables automatically.
<mask>
<mask> If `python-dotenv`_ is installed, running the ``flask`` command will set
<mask> environment variables defined in the files :file:`.env` an... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
your own Click script. Instead of using ``--app`` and letting Flask load | <mask> Custom Scripts
<mask> --------------
<mask>
<mask> When you are using the app factory pattern, it may be more convenient to define
<mask> your own Click script. Instead of using ``FLASK_APP`` and letting Flask load
<mask> your application, you can create your own Click object and export it as a
<mask> `c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
script is available. Note that you don't need to set ``--app``. :: | <mask> },
<mask> )
<mask>
<mask> Install the application in the virtualenv in editable mode and the custom
<mask> script is available. Note that you don't need to set ``FLASK_APP``. ::
<mask>
<mask> $ pip install -e .
<mask> $ wiki run
<mask>
<mask> .. admonition:: Errors in Custom Scri... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/cli.rst |
In order to set the environment and debug mode reliably, pass options to
the ``flask`` command or use environment variables. | <mask> ------------------------------
<mask>
<mask> The :data:`ENV` and :data:`DEBUG` config values are special because they
<mask> may behave inconsistently if changed after the app has begun setting up.
<mask> In order to set the environment and debug mode reliably, Flask uses
<mask> environment variables.
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/config.rst |
The execution environment is used to indicate to Flask, extensions, and
other programs, like Sentry, what context Flask is running in. It is
controlled with the ``FLASK_ENV`` environment variable, or the
``--env`` option when using the ``flask`` command, and defaults to
``production``. | <mask> may behave inconsistently if changed after the app has begun setting up.
<mask> In order to set the environment and debug mode reliably, Flask uses
<mask> environment variables.
<mask>
<mask> The environment is used to indicate to Flask, extensions, and other
<mask> programs, like Sentry, what context Fla... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/config.rst |
Setting ``--env development`` will enable debug mode. ``flask run`` will
use the interactive debugger and reloader by default in debug mode. To
control this separately from the environment, use the
``--debug/--no-debug`` option or the ``FLASK_DEBUG`` environment
variable. | <mask> programs, like Sentry, what context Flask is running in. It is
<mask> controlled with the :envvar:`FLASK_ENV` environment variable and
<mask> defaults to ``production``.
<mask>
<mask> Setting :envvar:`FLASK_ENV` to ``development`` will enable debug mode.
<mask> ``flask run`` will use the interactive debug... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/config.rst |
set ``--env``: | <mask> Added :envvar:`FLASK_ENV` to control the environment separately
<mask> from debug mode. The development environment enables debug mode.
<mask>
<mask> To switch Flask to the development environment and enable debug mode,
<mask> set :envvar:`FLASK_ENV`:
<mask>
<mask> .. tabs::
<mask>
<mask> ... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/config.rst |
.. code-block:: text | <mask> .. group-tab:: Fish
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ set -x FLASK_ENV development
<mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_ENV=development
<mask> > fla... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/config.rst |
$ flask --app hello --env development run | <mask> .. group-tab:: Powershell
<mask>
<mask> .. code-block:: text
<mask>
<mask> > $env:FLASK_ENV = "development"
<mask> > flask run
<mask>
<mask> Using the environment variables as described above is recommended. While
<mask> it is possible to set :data:`ENV` and :data:`DEBUG` i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/config.rst |
Using the options or environment variables as described above is
recommended. While it is possible to set :data:`ENV` and :data:`DEBUG`
in your config or code, this is strongly discouraged. They can't be read
early by the ``flask`` command, and some systems or extensions may have
already configured themselves based on ... | <mask>
<mask> > $env:FLASK_ENV = "development"
<mask> > flask run
<mask>
<mask> Using the environment variables as described above is recommended. While
<mask> it is possible to set :data:`ENV` and :data:`DEBUG` in your config or
<mask> code, this is strongly discouraged. They can't be read e... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/config.rst |
To enable the debugger, run the development server with the environment
set to ``development``. This puts Flask in debug mode, which changes how
it handles some errors, and enables the debugger and reloader. | <mask> browser. It is protected by a pin, but still represents a major
<mask> security risk. Do not run the development server or debugger in a
<mask> production environment.
<mask>
<mask> To enable the debugger, run the development server with the
<mask> ``FLASK_ENV`` environment variable set to ``d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/debugging.rst |
.. code-block:: text | <mask> ``FLASK_ENV`` environment variable set to ``development``. This puts
<mask> Flask in debug mode, which changes how it handles some errors, and
<mask> enables the debugger and reloader.
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
</s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/debugging.rst |
$ flask --app hello --env development run | <mask> enables the debugger and reloader.
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ export FLASK_ENV=development
<mask> $ flask run
</s> prefer --app over FLASK_APP in docs </s> remove .. tabs::
</s> add .. cod... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/debugging.rst |
``FLASK_ENV`` can also be set as an environment variable. When running | <mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> .. group-tab:: Fish
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ set -x FLASK_ENV dev... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/debugging.rst |
mostly equivalent. Debug mode can be controlled separately from the
environment with the ``--debug/--no-debug`` option or the
``FLASK_DEBUG`` environment variable. | <mask> > flask run
<mask>
<mask> ``FLASK_ENV`` can only be set as an environment variable. When running
<mask> from Python code, passing ``debug=True`` enables debug mode, which is
<mask> mostly equivalent. Debug mode can be controlled separately from
<mask> ``FLASK_ENV`` with the ``FLASK_DEBUG`` enviro... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/debugging.rst |
.. code-block:: text | <mask> When using an external debugger, the app should still be in debug mode,
<mask> but it can be useful to disable the built-in debugger and reloader,
<mask> which can interfere.
<mask>
<mask> When running from the command line:
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/debugging.rst |
$ flask --app hello --env development run --no-debugger --no-reload | <mask> .. group-tab:: Powershell
<mask>
<mask> .. code-block:: text
<mask>
<mask> > $env:FLASK_ENV = "development"
<mask> > flask run --no-debugger --no-reload
<mask>
<mask> When running from Python:
<mask>
<mask> .. code-block:: python
<mask>
</s> prefer --app over FLASK_APP... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/debugging.rst |
.. code-block:: text | <mask> ------------------
<mask>
<mask> To run such an application, you can use the :command:`flask` command:
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
</s> prefer --app over FLASK_APP in docs </s> remove .. group-tab:: Bash
</s> add... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/appfactories.rst |
$ flask run --app hello run | <mask> To run such an application, you can use the :command:`flask` command:
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ export FLASK_APP=myapp
<mask> $ flask run
</s> prefer --app over FLASK_APP in docs </s> remo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/appfactories.rst |
Flask will automatically detect the factory if it is named
``create_app`` or ``make_app`` in ``hello``. You can also pass arguments
to the factory like this: | <mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ export FLASK_APP=myapp
<mask> $ flask run
<mask>
<mask> .. group-tab:: Fish
</s> prefer --app over FLASK_APP in docs </s> remove $ export FLASK_APP=myapp
$... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/appfactories.rst |
.. code-block:: text | <mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ export FLASK_APP=myapp
<mask> $ flask run
<mask>
<mask> .. group-tab:: Fish
<mask>
<mask> .. code-block:: text
<mask>
</s> prefer --app over FLASK_APP in docs </s> remove .. group-tab:: ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/appfactories.rst |
$ flask run --app hello:create_app(local_auth=True)`` | <mask>
<mask> $ export FLASK_APP=myapp
<mask> $ flask run
<mask>
<mask> .. group-tab:: Fish
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ set -x FLASK_APP myapp
<mask> $ flask run
</s> prefer --app over FLASK_APP in docs </s> remove .. code-block:: ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/appfactories.rst |
Then the ``create_app`` factory in ``myapp`` is called with the keyword
argument ``local_auth=True``. See :doc:`/cli` for more detail. | <mask> $ flask run
<mask>
<mask> .. group-tab:: Fish
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ set -x FLASK_APP myapp
<mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_APP=my... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/appfactories.rst |
Install your application so it is importable: | <mask> 'flask',
<mask> ],
<mask> )
<mask>
<mask> In order to run the application you need to export an environment variable
<mask> that tells Flask where to find the application instance:
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
</s> prefer --app over F... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/packages.rst |
.. code-block:: text | <mask>
<mask> In order to run the application you need to export an environment variable
<mask> that tells Flask where to find the application instance:
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
</s> prefer --app over FLASK_APP in docs <... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/packages.rst |
$ pip install -e . | <mask> that tells Flask where to find the application instance:
<mask>
<mask> .. tabs::
<mask>
<mask> .. group-tab:: Bash
<mask>
<mask> .. code-block:: text
<mask>
<mask> $ export FLASK_APP=yourapplication
<mask>
<mask> .. group-tab:: Fish
<mask>
<mask> .. code-block:: text... | [
"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/ab1fbef29a073fe5950ea2357f6a3a0d280eb506 | docs/patterns/packages.rst |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.