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> self._implicit_app_ctx_stack.append(None)
<mask>
<mask> _request_ctx_stack.push(self)
<mask>
<mask> if self.url_adapter is not None:
<mask> self.match_request()
<mask>
<mask> # Open the session at the moment that the request context is available.
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | src/flask/ctx.py | |
# Match the request URL after loading the session, so that the
# session is available in custom URL converters.
if self.url_adapter is not None:
self.match_request()
| <mask> self.session = session_interface.make_null_session(self.app)
<mask>
<mask> def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore
<mask> """Pops the request context and unbinds it by doing that. This will
<mask> also trigger the execution of ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | src/flask/ctx.py |
from flask import request
from flask import session | <mask> from werkzeug.routing import BaseConverter
<mask>
<mask> from flask import has_request_context
<mask> from flask import url_for
<mask>
<mask>
<mask> def test_custom_converters(app, client):
<mask> class ListConverter(BaseConverter):
</s> converters have access to session </s> remove def test_open... | [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_converters.py |
assert request is not None
assert session is not None | <mask>
<mask> def test_context_available(app, client):
<mask> class ContextConverter(BaseConverter):
<mask> def to_python(self, value):
<mask> assert has_request_context()
<mask> return value
<mask>
<mask> app.url_map.converters["ctx"] = ContextConverter
<mask>
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_converters.py |
@app.get("/<ctx:name>") | <mask> return value
<mask>
<mask> app.url_map.converters["ctx"] = ContextConverter
<mask>
<mask> @app.route("/<ctx:name>")
<mask> def index(name):
<mask> return name
<mask>
<mask> assert client.get("/admin").data == b"admin"
</s> converters have access to session </s> re... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_converters.py |
def test_open_session_with_endpoint():
"""If request.endpoint (or other URL matching behavior) is needed
while loading the session, RequestContext.match_request() can be
called manually.
"""
| <mask> import flask
<mask> from flask.sessions import SessionInterface
<mask>
<mask>
<mask> def test_open_session_endpoint_not_none():
<mask> # Define a session interface that breaks if request.endpoint is None
<mask> class MySessionInterface(SessionInterface):
<mask> def save_session(self):
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_session_interface.py |
def save_session(self, app, session, response): | <mask>
<mask> def test_open_session_endpoint_not_none():
<mask> # Define a session interface that breaks if request.endpoint is None
<mask> class MySessionInterface(SessionInterface):
<mask> def save_session(self):
<mask> pass
<mask>
<mask> def open_session(self, _, request... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_session_interface.py |
def open_session(self, app, request):
flask._request_ctx_stack.top.match_request() | <mask> class MySessionInterface(SessionInterface):
<mask> def save_session(self):
<mask> pass
<mask>
<mask> def open_session(self, _, request):
<mask> assert request.endpoint is not None
<mask>
<mask> def index():
<mask> return "Hello World!"
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_session_interface.py |
<mask>
<mask> def open_session(self, _, request):
<mask> assert request.endpoint is not None
<mask>
<mask> def index():
<mask> return "Hello World!"
<mask>
<mask> # Confirm a 200 response, indicating that request.endpoint was NOT None
<mask> app = flask.Flask(__name__... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_session_interface.py | |
<mask> return "Hello World!"
<mask>
<mask> # Confirm a 200 response, indicating that request.endpoint was NOT None
<mask> app = flask.Flask(__name__)
<mask> app.route("/")(index)
<mask> app.session_interface = MySessionInterface()
<mask> response = app.test_client().open("/")
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_session_interface.py | |
@app.get("/")
def index():
return "Hello, World!"
response = app.test_client().get("/") | <mask> # Confirm a 200 response, indicating that request.endpoint was NOT None
<mask> app = flask.Flask(__name__)
<mask> app.route("/")(index)
<mask> app.session_interface = MySessionInterface()
<mask> response = app.test_client().open("/")
<mask> assert response.status_code == 200
</s> c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | tests/test_session_interface.py |
packaging==20.8 # via -r requirements/docs.in, pallets-sphinx-themes, pytest, sphinx, tox | <mask> iniconfig==1.1.1 # via pytest
<mask> jinja2==2.11.2 # via sphinx
<mask> markupsafe==1.1.1 # via jinja2
<mask> nodeenv==1.5.0 # via pre-commit
<mask> packaging==20.4 # via -r requirements/docs.in, pallets-sphinx-themes, pytest, sphinx, tox
<mask> pallets-sphi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7cf23a2343e04e61bb770d373a29e2666c56330 | requirements/dev.txt |
six==1.15.0 # via tox, virtualenv | <mask> python-dotenv==0.15.0 # via -r requirements/tests.in
<mask> pytz==2020.1 # via babel
<mask> pyyaml==5.3.1 # via pre-commit
<mask> requests==2.24.0 # via sphinx
<mask> six==1.15.0 # via packaging, tox, virtualenv
<mask> snowballstemmer==2.0.0 # via sphi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7cf23a2343e04e61bb770d373a29e2666c56330 | requirements/dev.txt |
packaging==20.8 # via -r requirements/docs.in, pallets-sphinx-themes, sphinx | <mask> idna==2.10 # via requests
<mask> imagesize==1.2.0 # via sphinx
<mask> jinja2==2.11.2 # via sphinx
<mask> markupsafe==1.1.1 # via jinja2
<mask> packaging==20.4 # via -r requirements/docs.in, pallets-sphinx-themes, sphinx
<mask> pallets-sphinx-themes==1.2.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7cf23a2343e04e61bb770d373a29e2666c56330 | requirements/docs.txt |
<mask> pygments==2.7.2 # via sphinx, sphinx-tabs
<mask> pyparsing==2.4.7 # via packaging
<mask> pytz==2020.1 # via babel
<mask> requests==2.24.0 # via sphinx
<mask> six==1.15.0 # via packaging
<mask> snowballstemmer==2.0.0 # via sphinx
<mask> sphinx-issue... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7cf23a2343e04e61bb770d373a29e2666c56330 | requirements/docs.txt | |
packaging==20.8 # via pytest | <mask> attrs==20.2.0 # via pytest
<mask> blinker==1.4 # via -r requirements/tests.in
<mask> greenlet==0.4.17 # via -r requirements/tests.in
<mask> iniconfig==1.1.1 # via pytest
<mask> packaging==20.4 # via pytest
<mask> pluggy==0.13.1 # via pytest
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7cf23a2343e04e61bb770d373a29e2666c56330 | requirements/tests.txt |
<mask> py==1.9.0 # via pytest
<mask> pyparsing==2.4.7 # via packaging
<mask> pytest==6.1.2 # via -r requirements/tests.in
<mask> python-dotenv==0.15.0 # via -r requirements/tests.in
<mask> six==1.15.0 # via packaging
<mask> toml==0.10.2 # via pyt... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/a7cf23a2343e04e61bb770d373a29e2666c56330 | requirements/tests.txt | |
<mask>
<mask> Marks a function so that an instance of :class:`ScriptInfo` is passed
<mask> as first argument to the click callback.
<mask>
<mask> .. autofunction:: script_info_option
<mask>
<mask> A special decorator that informs a click callback to be passed the
<mask> script info object as firs... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/api.rst | |
Given a :file:`hello.py` file with the application in it named ``app``
this is how it can be run. | <mask>
<mask> In that imported file the name of the app needs to be called ``app`` or
<mask> optionally be specified after a colon.
<mask>
<mask> Given a :file:`hello.py` file with the application in it named ``app`` this is
<mask> how it can be run.
<mask>
<mask> Environment variables (On Windows use ``set`... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
Or with a filename:: | <mask>
<mask> export FLASK_APP=hello
<mask> flask run
<mask>
<mask> Parameters::
<mask>
<mask> flask --app=hello run
<mask>
<mask> File names::
<mask>
</s> Update docs to the new CLI patterns </s> remove flask --app=hello run
File names::
flask --app=hello.py run
</s> add expo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
export FLASK_APP=/path/to/hello.py
flask run | <mask> flask run
<mask>
<mask> Parameters::
<mask>
<mask> flask --app=hello run
<mask>
<mask> File names::
<mask>
<mask> flask --app=hello.py run
<mask>
<mask> Virtualenv Integration
<mask> ----------------------
<mask>
<mask> If you are constantly working with a virtualenv you can also ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
The :command:`flask` script can also be instructed to enable the debug
mode of the application automatically by exporting ``FLASK_DEBUG``. If
set to ``1`` debug is enabled or ``0`` disables it.
Or with a filename::
export FLASK_DEBUG=1 | <mask>
<mask> Debug Flag
<mask> ----------
<mask>
<mask> The :command:`flask` script can be run with :option:`--debug` or :option:`--no-debug` to
<mask> automatically flip the debug flag of the application. This can also be
<mask> configured by setting ``FLASK_DEBUG`` to ``1`` or ``0``.
<mask>
<mask> Runni... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
flask shell | <mask> ---------------
<mask>
<mask> To run an interactive Python shell you can use the ``shell`` command::
<mask>
<mask> flask --app=hello shell
<mask>
<mask> This will start up an interactive Python shell, setup the correct
<mask> application context and setup the local variables in the shell. This is... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
import click | <mask> easily. Flask uses `click`_ for the command interface which makes
<mask> creating custom commands very easy. For instance if you want a shell
<mask> command to initialize the database you can do this::
<mask>
<mask> from flask import Flask
<mask>
<mask> app = Flask(__name__)
<mask>
</s> Upd... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
click.echo('Init the db') | <mask>
<mask> @app.cli.command()
<mask> def initdb():
<mask> """Initialize the database."""
<mask> print 'Init the db'
<mask>
<mask> The command will then show up on the command line::
<mask>
<mask> $ flask -a hello.py initdb
<mask> Init the db
</s> Update docs to the new C... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
$ flask initdb | <mask> print 'Init the db'
<mask>
<mask> The command will then show up on the command line::
<mask>
<mask> $ flask -a hello.py initdb
<mask> Init the db
<mask>
<mask> Application Context
<mask> -------------------
<mask>
</s> Update docs to the new CLI patterns </s> remove print '... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
:ref:`app-factories`) you will discover that the :command:`flask` command
cannot work with them directly. Flask won't be able to figure out how to | <mask> Factory Functions
<mask> -----------------
<mask>
<mask> In case you are using factory functions to create your application (see
<mask> :ref:`app-factories`) you will discover that the :command:`flask` command cannot
<mask> work with them directly. Flask won't be able to figure out how to
<mask> instant... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
applications. This is not the only way to make this work. Another is the
:ref:`custom-scripts` support. | <mask> :ref:`app-factories`) you will discover that the :command:`flask` command cannot
<mask> work with them directly. Flask won't be able to figure out how to
<mask> instantiate your application properly by itself. Because of this reason
<mask> the recommendation is to create a separate file that instantiates
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
While the most common way is to use the :command:`flask` command, you can
also make your own "driver scripts". Since Flask uses click for the
scripts there is no reason you cannot hook these scripts into any click | <mask>
<mask> Custom Scripts
<mask> --------------
<mask>
<mask> While the most common way is to use the :command:`flask` command, you can also
<mask> make your own "driver scripts". Since Flask uses click for the scripts
<mask> there is no reason you cannot hook these scripts into any click
<mask> applicati... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
click finds and executes the Flask application. If you use the
:command:`flask` script you specify the application to work with on the
command line or environment variable as an import name. This is simple
but it has some limitations. Primarily it does not work with application
factory functions (see :ref:`app-facto... | <mask> necessary so that the commands know which Flask application they have to
<mask> work with.
<mask>
<mask> To understand why you might want custom scripts you need to understand how
<mask> click finds and executes the Flask application. If you use the :command:`flask`
<mask> script you specify the applicat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
<mask> customize how the application will be created. This is very useful if you
<mask> write reusable applications that you want to ship to users and they should
<mask> be presented with a custom management script.
<mask>
<mask> If you are used to writing click applications this will look familiar but
<mask> a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst | |
import os | <mask> manages a hypothetical wiki application. We will go through the details
<mask> afterwards::
<mask>
<mask> import click
<mask> from flask.cli import FlaskGroup
<mask>
<mask> def create_wiki_app(info):
<mask> from yourwiki import create_app
</s> Update docs to the new CLI patterns <... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
from flask.cli import FlaskGroup | <mask> manages a hypothetical wiki application. We will go through the details
<mask> afterwards::
<mask>
<mask> import click
<mask> from flask.cli import FlaskGroup, script_info_option
<mask>
<mask> def create_wiki_app(info):
<mask> from yourwiki import create_app
<mask> config ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
return create_app(
config=os.environ.get('WIKI_CONFIG', 'wikiconfig.py')) | <mask> from flask.cli import FlaskGroup, script_info_option
<mask>
<mask> def create_wiki_app(info):
<mask> from yourwiki import create_app
<mask> config = info.data.get('config') or 'wikiconfig.py'
<mask> return create_app(config=config)
<mask>
<mask> @click.group(cls=Flas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
def cli(): | <mask> config = info.data.get('config') or 'wikiconfig.py'
<mask> return create_app(config=config)
<mask>
<mask> @click.group(cls=FlaskGroup, create_app=create_wiki_app)
<mask> @script_info_option('--config', script_info_key='config')
<mask> def cli(**params):
<mask> """This ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
in the :class:`~flask.cli.FlaskGroup` click group. | <mask> step.
<mask>
<mask> 1. First we import the ``click`` library as well as the click extensions
<mask> from the ``flask.cli`` package. Primarily we are here interested
<mask> in the :class:`~flask.cli.FlaskGroup` click group and the
<mask> :func:`~flask.cli.script_info_option` decorator.
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
script info object (:class:`~flask.cli.ScriptInfo`) from Flask and its | <mask> from the ``flask.cli`` package. Primarily we are here interested
<mask> in the :class:`~flask.cli.FlaskGroup` click group and the
<mask> :func:`~flask.cli.script_info_option` decorator.
<mask> 2. The next thing we do is defining a function that is invoked with the
<mask> script info object... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
:ref:`app-factories`). In this case we load the config from an
environment variable. | <mask> 2. The next thing we do is defining a function that is invoked with the
<mask> script info object (:ref:`script-info-object`) from Flask and its
<mask> purpose is to fully import and create the application. This can
<mask> either directly import an application object or create it (see
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
4. All is rounded up by invoking the script. | <mask> and then pass the ``create_wiki_app`` function as a factory function.
<mask>
<mask> Whenever click now needs to operate on a Flask application it will
<mask> call that function with the script info and ask for it to be created.
<mask> 4. In step 2 you could see that the config is passed to the... | [
"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/a7d829c61854bc609a343eec114d2a129761fe9f | docs/cli.rst |
export FLASK_APP=exampleapp
flask run | <mask> app = create_app('/path/to/config.cfg')
<mask>
<mask> It can then be used with the :command:`flask` command::
<mask>
<mask> flask --app=exampleapp run
<mask>
<mask> Factory Improvements
<mask> --------------------
<mask>
<mask> The factory function from above is not very clever so far, you ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/patterns/appfactories.rst |
python's :option:`-m` switch with Flask. Before you can do that you need
to tell your terminal the application to work with by exporting the
`FLASK_APP` environment variable:: | <mask> interpreter. Make sure to not call your application :file:`flask.py` because this
<mask> would conflict with Flask itself.
<mask>
<mask> To run the application you can either use the :command:`flask` command or
<mask> python's :option:`-m` switch with Flask::
<mask>
<mask> $ flask -a hello run
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
$ export FLASK_APP=hello.py
$ flask run | <mask>
<mask> To run the application you can either use the :command:`flask` command or
<mask> python's :option:`-m` switch with Flask::
<mask>
<mask> $ flask -a hello run
<mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> or alternatively::
<mask>
<mask> $ python -m flask -a hello run
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
If you are on Windows you need to use `set` instead of `export`. | <mask>
<mask> $ flask -a hello run
<mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> or alternatively::
<mask>
<mask> $ python -m flask -a hello run
<mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> This launches a very simple builtin server, which is good enough for testin... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
Alternatively you can use `python -m flask`::
$ export FLASK_APP=hello.py
$ python -m flask run | <mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> or alternatively::
<mask>
<mask> $ python -m flask -a hello run
<mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> This launches a very simple builtin server, which is good enough for testing
<mask> but probably not what you want t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
flask run --host=0.0.0.0 | <mask> If you have the debugger disabled or trust the users on your network,
<mask> you can make the server publicly available simply by adding
<mask> ``--host=0.0.0.0`` to the command line::
<mask>
<mask> flask -a hello run --host=0.0.0.0
<mask>
<mask> This tells your operating system to li... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
Versions of Flask older than 0.11 use to have different ways to start the | <mask>
<mask> Old Version of Flask
<mask> ````````````````````
<mask>
<mask> Versions of Flask older than 1.0 use to have different ways to start the
<mask> application. In short, the :command:`flask` command did not exist, and
<mask> neither did ``python -m flask``. In that case you have two options:
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
<mask> neither did ``python -m flask``. In that case you have two options:
<mask> either upgrade to newer Flask versions or have a look at the :ref:`server`
<mask> docs to see the alternative method for running a server.
<mask>
<mask> Python older 2.7
<mask> ````````````````
<mask>
<mask> In case you have a ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst | |
The :option:`-a` argument to :command:`flask` is the name of the module to
import. In case that module is incorrectly named you will get an import
error upon start (or if debug is enabled when you navigate to the
application). It will tell you what it tried to import and why it failed. | <mask>
<mask> Invalid Import Name
<mask> ```````````````````
<mask>
<mask> The :option:`-a` argument to :command:`flask` is the name of the module to import. In
<mask> case that module is incorrectly named you will get an import error upon
<mask> start (or if debug is enabled when you navigate to the applicat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
To enable debug mode you can export the `FLASK_DEBUG` environment variable
before running the server::
$ export FLASK_DEBUG=1
$ flask run | <mask> That is not very nice and Flask can do better. If you enable debug
<mask> support the server will reload itself on code changes, and it will also
<mask> provide you with a helpful debugger if things go wrong.
<mask>
<mask> There are different ways to enable the debug mode. The most obvious one
<mask> is... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
(On Windows you need to use `set` instead of `export`). | <mask>
<mask> There are different ways to enable the debug mode. The most obvious one
<mask> is the :option:`--debug` parameter to the :command:`flask` command::
<mask>
<mask> flask --debug -a hello run
<mask>
<mask> This does the following things:
<mask>
<mask> 1. it activates the debugger
<mask> 2... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/quickstart.rst |
flask initdb | <mask> databases will not commit unless you explicitly tell it to.
<mask>
<mask> Now, it is possible to create a database with the :command:`flask` script::
<mask>
<mask> flask --app=flaskr initdb
<mask> Initialized the database.
<mask>
<mask> .. admonition:: Troubleshooting
<mask>
<mask> If yo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/tutorial/dbinit.rst |
without problems. Do this with the following commands:: | <mask> rv.row_factory = sqlite3.Row
<mask> return rv
<mask>
<mask> With that out of the way, you should be able to start up the application
<mask> without problems. Do this with the following command::
<mask>
<mask> flask --app=flaskr --debug run
<mask>
<mask> The :option:`--debug` flag... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/tutorial/setup.rst |
export FLASK_APP=flaskr
export FLASK_DEBUG=1
flask run | <mask>
<mask> With that out of the way, you should be able to start up the application
<mask> without problems. Do this with the following command::
<mask>
<mask> flask --app=flaskr --debug run
<mask>
<mask> The :option:`--debug` flag enables or disables the interactive debugger. *Never
<mask> leave de... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/tutorial/setup.rst |
(In case you are on Windows you need to use `set` instead of `export`).
The :envvar:`FLASK_DEBUG` flag enables or disables the interactive debugger.
*Never leave debug mode activated in a production system*, because it will
allow users to execute code on the server! | <mask> without problems. Do this with the following command::
<mask>
<mask> flask --app=flaskr --debug run
<mask>
<mask> The :option:`--debug` flag enables or disables the interactive debugger. *Never
<mask> leave debug mode activated in a production system*, because it will allow
<mask> users to execute... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | docs/tutorial/setup.rst |
2. Instruct flask to use the right application | <mask> 1. edit the configuration in the flaskr.py file or
<mask> export an FLASKR_SETTINGS environment variable
<mask> pointing to a configuration file.
<mask>
<mask> 2. initialize the database with this command:
<mask>
<mask> flask --app=flaskr initdb
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | examples/flaskr/README |
export FLASK_APP=flaskr | <mask> pointing to a configuration file.
<mask>
<mask> 2. initialize the database with this command:
<mask>
<mask> flask --app=flaskr initdb
<mask>
<mask> 3. now you can run flaskr:
<mask>
<mask> flask --app=flaskr run
<mask>
</s> Update docs to the new CLI pattern... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | examples/flaskr/README |
3. initialize the database with this command: | <mask> 2. initialize the database with this command:
<mask>
<mask> flask --app=flaskr initdb
<mask>
<mask> 3. now you can run flaskr:
<mask>
<mask> flask --app=flaskr run
<mask>
<mask> the application will greet you on
<mask> http://localhost:5000/
</s> Upd... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | examples/flaskr/README |
flask initdb
4. now you can run flaskr:
flask run | <mask> flask --app=flaskr initdb
<mask>
<mask> 3. now you can run flaskr:
<mask>
<mask> flask --app=flaskr run
<mask>
<mask> the application will greet you on
<mask> http://localhost:5000/
<mask>
<mask> ~ Is it tested?
</s> Update docs to the new CLI patterns... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | examples/flaskr/README |
2. tell flask about the right application:
export FLASK_APP=minitwit
| <mask> 1. edit the configuration in the minitwit.py file or
<mask> export an MINITWIT_SETTINGS environment variable
<mask> pointing to a configuration file.
<mask>
<mask> 2. fire up a shell and run this:
<mask>
<mask> flask initdb
<mask>
<mask> 3. now you can run... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | examples/minitwit/README |
flask initdb | <mask> pointing to a configuration file.
<mask>
<mask> 2. fire up a shell and run this:
<mask>
<mask> flask --app=minitwit initdb
<mask>
<mask> 3. now you can run minitwit:
<mask>
<mask> flask --app=minitwit run
<mask>
</s> Update docs to the new CLI patterns </s> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | examples/minitwit/README |
flask run | <mask> flask --app=minitwit initdb
<mask>
<mask> 3. now you can run minitwit:
<mask>
<mask> flask --app=minitwit run
<mask>
<mask> the application will greet you on
<mask> http://localhost:5000/
<mask>
<mask> ~ Is it tested?
</s> Update docs to the new CLI pa... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | examples/minitwit/README |
to click. In future versions of Flask this object will most likely play
a bigger role. Typically it's created automatically by the
:class:`FlaskGroup` but you can also manually create it and pass it
onwards as click object. | <mask>
<mask> class ScriptInfo(object):
<mask> """Help object to deal with Flask applications. This is usually not
<mask> necessary to interface with as it's used internally in the dispatching
<mask> to click.
<mask> """
<mask>
<mask> def __init__(self, app_import_path=None, create_app=No... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | flask/cli.py |
app_import_path = None
#: Optionally the import path for the Flask application.
self.app_import_path = app_import_path | <mask> if app_import_path is None:
<mask> app_import_path = find_default_import_path()
<mask> self.app_import_path = app_import_path
<mask> else:
<mask> self.app_import_path = None
<mask> #: Optionally a function that is passed the script info to... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | flask/cli.py |
if not self.app_import_path:
raise NoAppException(
'Could not locate Flask application. You did not provide '
'the FLASK_APP environment variable.\n\nFor more '
'information see '
'http://flask.pocoo.org/docs/lat... | <mask> return self._loaded_app
<mask> if self.create_app is not None:
<mask> rv = self.create_app(self)
<mask> else:
<mask> if self.app_import_path is None:
<mask> raise NoAppException('Could not locate Flask application. '
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | flask/cli.py |
if debug is not None:
print(' * Forcing debug mode %s' % (debug and 'on' or 'off')) | <mask> # we won't print anything.
<mask> if info.app_import_path is not None:
<mask> print(' * Serving Flask app "%s"' % info.app_import_path)
<mask>
<mask> run_simple(host, port, app, use_reloader=reload,
<mask> use_debugger=debugger, threaded=with_threads)
<mask>... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7d829c61854bc609a343eec114d2a129761fe9f | flask/cli.py |
- Change default configuration `JSONIFY_PRETTYPRINT_REGULAR=False`. jsonify()
method returns compressed response by default, and pretty response in
debug mode. | <mask> - Make `app.run()` into a noop if a Flask application is run from the
<mask> development server on the command line. This avoids some behavior that
<mask> was confusing to debug for newcomers.
<mask>
<mask> Version 0.12.1
<mask> --------------
<mask>
<mask> Bugfix release, unreleased
<mask>
</s... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7f1a21c1204828388eaed1e3903a74c904c8147 | CHANGES |
``JSONIFY_PRETTYPRINT_REGULAR`` If this is set to ``True`` or the Flask app
is running in debug mode, jsonify responses
will be pretty printed. | <mask> behavior by changing this variable.
<mask> This is not recommended but might give
<mask> you a performance improvement on the
<mask> cost of cacheability.
<mask> ``JSONIFY_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7f1a21c1204828388eaed1e3903a74c904c8147 | docs/config.rst |
'JSONIFY_PRETTYPRINT_REGULAR': False, | <mask> 'EXPLAIN_TEMPLATE_LOADING': False,
<mask> 'PREFERRED_URL_SCHEME': 'http',
<mask> 'JSON_AS_ASCII': True,
<mask> 'JSON_SORT_KEYS': True,
<mask> 'JSONIFY_PRETTYPRINT_REGULAR': True,
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7f1a21c1204828388eaed1e3903a74c904c8147 | flask/app.py |
if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] or current_app.debug: | <mask>
<mask> indent = None
<mask> separators = (',', ':')
<mask>
<mask> if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
<mask> indent = 2
<mask> separators = (', ', ': ')
<mask>
<mask> if args and kwargs:
<mask> raise TypeError('jsonify(... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7f1a21c1204828388eaed1e3903a74c904c8147 | flask/json.py |
assert rv.data == b'{"msg":"W00t"}\n' | <mask> with app.test_request_context():
<mask> rv = flask.make_response(
<mask> flask.jsonify({'msg': 'W00t'}), 400)
<mask> assert rv.status_code == 400
<mask> assert rv.data == b'{\n "msg": "W00t"\n}\n'
<mask> assert rv.mimetype == 'application/json'
<mask>
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7f1a21c1204828388eaed1e3903a74c904c8147 | tests/test_basic.py |
app.debug = True
| <mask>
<mask> def test_json_key_sorting(self):
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> assert app.config['JSON_SORT_KEYS'] == True
<mask> d = dict.fromkeys(range(20), 'foo')
<mask>
<mask> @app.route('/')
<mask> def index():
<mas... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7f1a21c1204828388eaed1e3903a74c904c8147 | tests/test_helpers.py |
- ``app.json_encoder`` and ``json_decoder`` are only passed to
``dumps`` and ``loads`` if they have custom behavior. This improves
performance, mainly on PyPy. :issue:`4349` | <mask> 2.0.x. Use ``response.request.environ`` instead. :pr:`4341`
<mask> - Fix type annotation for ``errorhandler`` decorator. :issue:`4295`
<mask> - Revert a change to the CLI that caused it to hide ``ImportError``
<mask> tracebacks when importing the application. :issue:`4307`
<mask>
<mask>
<mas... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a841cfabb58d3c1ac1d11b09353f458e759a63c2 | CHANGES.rst |
# Only set a custom encoder if it has custom behavior. This is
# faster on PyPy.
if cls is not _json.JSONEncoder:
kwargs.setdefault("cls", cls)
| <mask> if bp is not None and bp.json_encoder is not None:
<mask> cls = bp.json_encoder
<mask>
<mask> kwargs.setdefault("cls", cls)
<mask> kwargs.setdefault("ensure_ascii", app.config["JSON_AS_ASCII"])
<mask> kwargs.setdefault("sort_keys", app.config["JSON_SORT_KEYS"])
... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a841cfabb58d3c1ac1d11b09353f458e759a63c2 | src/flask/json/__init__.py |
# Only set a custom decoder if it has custom behavior. This is
# faster on PyPy.
if cls not in {JSONDecoder, _json.JSONDecoder}:
kwargs.setdefault("cls", cls) | <mask> bp = app.blueprints.get(request.blueprint) if request else None # type: ignore
<mask> if bp is not None and bp.json_decoder is not None:
<mask> cls = bp.json_decoder
<mask>
<mask> kwargs.setdefault("cls", cls)
<mask> else:
<mask> kwargs.setdefault("cls", J... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a841cfabb58d3c1ac1d11b09353f458e759a63c2 | src/flask/json/__init__.py |
- When passing a full URL to the test client, use the scheme in the URL instead
of the ``PREFERRED_URL_SCHEME``. (`#2436`_) | <mask> ``test_client.open``. (`#2412`_)
<mask> - The ``flask`` command and ``app.run`` will load environment variables using
<mask> from ``.env`` and ``.flaskenv`` files if python-dotenv is installed.
<mask> (`#2416`_)
<mask>
<mask> .. _#1421: https://github.com/pallets/flask/issues/1421
<mask> .. _#1489:... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a89bdb3395b22c963456d1fcdebbd77c5c6f618c | CHANGES |
.. _#2436: https://github.com/pallets/flask/pull/2436 | <mask> .. _#2412: https://github.com/pallets/flask/pull/2412
<mask> .. _#2414: https://github.com/pallets/flask/pull/2414
<mask> .. _#2416: https://github.com/pallets/flask/pull/2416
<mask>
<mask> Version 0.12.2
<mask> --------------
<mask>
<mask> Released on May 16 2017
</s> prefer the url's scheme over the... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a89bdb3395b22c963456d1fcdebbd77c5c6f618c | CHANGES |
<mask>
<mask> if subdomain:
<mask> http_host = '{0}.{1}'.format(subdomain, http_host)
<mask>
<mask> url = url_parse(path)
<mask> if url_scheme is None:
<mask> url_scheme = url.scheme or app.config['PREFERRED_URL_SCHEME']
<mask>
<mask> base_url = '{0}://{1}/{2... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a89bdb3395b22c963456d1fcdebbd77c5c6f618c | flask/testing.py | |
url_scheme = app.config['PREFERRED_URL_SCHEME'] | <mask> http_host = '{0}.{1}'.format(subdomain, http_host)
<mask>
<mask> url = url_parse(path)
<mask> if url_scheme is None:
<mask> url_scheme = url.scheme or app.config['PREFERRED_URL_SCHEME']
<mask>
<mask> base_url = '{0}://{1}/{2}'.format(
<mask> url_sche... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a89bdb3395b22c963456d1fcdebbd77c5c6f618c | flask/testing.py |
url = url_parse(path)
base_url = '{scheme}://{netloc}/{path}'.format(
scheme=url.scheme or url_scheme,
netloc=url.netloc or http_host,
path=app_root.lstrip('/') | <mask> url = url_parse(path)
<mask> if url_scheme is None:
<mask> url_scheme = url.scheme or app.config['PREFERRED_URL_SCHEME']
<mask>
<mask> base_url = '{0}://{1}/{2}'.format(
<mask> url_scheme, url.netloc or http_host, app_root.lstrip('/')
<mask> )
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a89bdb3395b22c963456d1fcdebbd77c5c6f618c | flask/testing.py |
def test_path_is_url(app):
eb = make_test_environ_builder(app, 'https://example.com/')
assert eb.url_scheme == 'https'
assert eb.host == 'example.com'
assert eb.script_root == ''
assert eb.path == '/'
| <mask> assert rv.data == b'https://localhost/'
<mask>
<mask>
<mask> def test_blueprint_with_subdomain(app, client):
<mask> app.config['SERVER_NAME'] = 'example.com:1234'
<mask> app.config['APPLICATION_ROOT'] = '/foo'
<mask>
</s> prefer the url's scheme over the kwarg
tabs -> spaces
add test
add c... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a89bdb3395b22c963456d1fcdebbd77c5c6f618c | tests/test_testing.py |
Flask depends on some external libraries, like `Werkzeug | <mask>
<mask> Installation
<mask> ============
<mask>
<mask> Flask depends on two external libraries, `Werkzeug
<mask> <http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_.
<mask> Werkzeug is a toolkit for WSGI, the standard Python interface between web
<mask> applications and a variety of... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
You will need Python 2.6 or newer to get started, so be sure to have an | <mask> So how do you get all that on your computer quickly? There are many ways you
<mask> could do that, but the most kick-ass method is virtualenv, so let's have a look
<mask> at that first.
<mask>
<mask> You will need Python 2.6 or higher to get started, so be sure to have an
<mask> up-to-date Python 2.x ins... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
Installing setuptools, pip............done. | <mask> $ mkdir myproject
<mask> $ cd myproject
<mask> $ virtualenv venv
<mask> New python executable in venv/bin/python
<mask> Installing distribute............done.
<mask>
<mask> Now, whenever you want to work on a project, you only have to activate the
<mask> corresponding environment. O... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
$ virtualenv venv | <mask>
<mask> $ git clone http://github.com/mitsuhiko/flask.git
<mask> Initialized empty Git repository in ~/dev/flask/.git/
<mask> $ cd flask
<mask> $ virtualenv venv --distribute
<mask> New python executable in venv/bin/python
<mask> Installing distribute............done.
<mask> $... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
Installing setuptools, pip............done. | <mask> Initialized empty Git repository in ~/dev/flask/.git/
<mask> $ cd flask
<mask> $ virtualenv venv --distribute
<mask> New python executable in venv/bin/python
<mask> Installing distribute............done.
<mask> $ . venv/bin/activate
<mask> $ python setup.py develop
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
$ virtualenv venv | <mask> To just get the development version without git, do this instead::
<mask>
<mask> $ mkdir flask
<mask> $ cd flask
<mask> $ virtualenv venv --distribute
<mask> $ . venv/bin/activate
<mask> New python executable in venv/bin/python
<mask> Installing distribute............done.
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
Installing setuptools, pip............done. | <mask> $ cd flask
<mask> $ virtualenv venv --distribute
<mask> $ . venv/bin/activate
<mask> New python executable in venv/bin/python
<mask> Installing distribute............done.
<mask> $ pip install Flask==dev
<mask> ...
<mask> Finished processing dependencies for Flask==dev
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
`pip` and `setuptools` on Windows
---------------------------------
Sometimes getting the standard "Python packaging tools" like *pip*, *setuptools*
and *virtualenv* can be a little trickier, but nothing very hard. The two crucial
packages you will need are setuptools and pip - these will let you install
anything else... | <mask> Finished processing dependencies for Flask==dev
<mask>
<mask> .. _windows-easy-install:
<mask>
<mask> `pip` and `distribute` on Windows
<mask> -----------------------------------
<mask>
<mask> On Windows, installation of `easy_install` is a little bit trickier, but still
<mask> quite easy. The e... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
To install the latest setuptools, you can use its bootstrap file: | <mask>
<mask> `pip` and `distribute` on Windows
<mask> -----------------------------------
<mask>
<mask> On Windows, installation of `easy_install` is a little bit trickier, but still
<mask> quite easy. The easiest way to do it is to download the
<mask> `distribute_setup.py`_ file and run it. The easiest way... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
`ez_setup.py`_ | <mask> quite easy. The easiest way to do it is to download the
<mask> `distribute_setup.py`_ file and run it. The easiest way to run the file is to
<mask> open your downloads folder and double-click on the file.
<mask>
<mask> Next, add the `easy_install` command and other Python scripts to the
<mask> command s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
Either should be double-clickable once you download them. If you already have pip,
you can upgrade them by running:: | <mask>
<mask> `ez_setup.py`_
<mask>
<mask>
<mask> > pip install --upgrade pip setuptools
<mask>
<mask> Most often, once you pull up a command prompt you want to be able to type ``pip``
<mask> and ``python`` which will run those things, but this might not automatically happen
</s> Update windows install... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
> pip install --upgrade pip setuptools | <mask> delimit it from existing values with a semicolon. Assuming you are using
<mask> Python 2.7 on the default path, add the following value::
<mask>
<mask>
<mask> ;C:\Python27\Scripts
<mask>
<mask> And you are done! To check that it worked, open the Command Prompt and execute
<mask> ``easy_install``... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
Most often, once you pull up a command prompt you want to be able to type ``pip``
and ``python`` which will run those things, but this might not automatically happen
on Windows, because it doesn't know where those executables are (give either a try!). | <mask>
<mask>
<mask> ;C:\Python27\Scripts
<mask>
<mask> And you are done! To check that it worked, open the Command Prompt and execute
<mask> ``easy_install``. If you have User Account Control enabled on Windows Vista or
<mask> Windows 7, it should prompt you for administrator privileges.
<mask>
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
To fix this, you should be able to navigate to your Python install directory
(e.g ``C:\Python27``), then go to ``Tools``, then ``Scripts``; then find the
``win_add2path.py`` file and run that. Open a **new** Command Prompt and
check that you can now just type ``python`` to bring up the interpreter. | <mask> And you are done! To check that it worked, open the Command Prompt and execute
<mask> ``easy_install``. If you have User Account Control enabled on Windows Vista or
<mask> Windows 7, it should prompt you for administrator privileges.
<mask>
<mask> Now that you have ``easy_install``, you can use it to ins... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
Finally, to install `virtualenv`_, you can simply run:: | <mask> Windows 7, it should prompt you for administrator privileges.
<mask>
<mask> Now that you have ``easy_install``, you can use it to install ``pip``::
<mask>
<mask> > easy_install pip
<mask>
<mask>
<mask> .. _distribute_setup.py: http://python-distribute.org/distribute_setup.py
</s> Update windows ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
> pip install virtualenv
Then you can be off on your way following the installation instructions above. | <mask> check that you can now just type ``python`` to bring up the interpreter.
<mask>
<mask> Finally, to install `virtualenv`_, you can simply run::
<mask>
<mask>
<mask> .. _get-pip.py: https://raw.github.com/pypa/pip/master/contrib/get-pip.py
<mask> .. _ez_setup.py: https://bitbucket.org/pypa/setuptools/raw... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
.. _get-pip.py: https://raw.github.com/pypa/pip/master/contrib/get-pip.py
.. _ez_setup.py: https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | <mask>
<mask> > easy_install pip
<mask>
<mask>
<mask> .. _distribute_setup.py: http://python-distribute.org/distribute_setup.py
</s> Update windows installation and other notes
Making allowance for new convenience of `get-pip.py` that automatically installs setuptools and pip together.
Stop recommendin... | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/pallets/flask/commit/a8e88bebd1dff6b982d721c781d87888ef756e4a | docs/installation.rst |
if sys.version_info < (2, 7, 9): | <mask> return value
<mask>
<mask> obj = import_string(value, silent=True)
<mask>
<mask> if sys.version_info < (2, 7):
<mask> if obj:
<mask> return obj
<mask> else:
<mask> if isinstance(obj, ssl.SSLContext)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a913b4dafd1d85cfa1d8bafeea5417748de8d487 | flask/cli.py |
if sys.version_info < (2, 7, 9): | <mask> """
<mask> cert = ctx.params.get('cert')
<mask> is_adhoc = cert == 'adhoc'
<mask>
<mask> if sys.version_info < (2, 7):
<mask> is_context = cert and not isinstance(cert, (text_type, bytes))
<mask> else:
<mask> is_context = isinstance(cert, ssl.SSLContext)
<mask>
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a913b4dafd1d85cfa1d8bafeea5417748de8d487 | flask/cli.py |
if sys.version_info >= (2, 7, 9): | <mask> with pytest.raises(click.BadParameter):
<mask> run_command.make_context('run', ['--cert', 'not_here'])
<mask>
<mask> # not an SSLContext
<mask> if sys.version_info >= (2, 7):
<mask> with pytest.raises(click.BadParameter):
<mask> run_command.make_context('run', ['--... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a913b4dafd1d85cfa1d8bafeea5417748de8d487 | tests/test_cli.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.