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 |
|---|---|---|---|---|
1 // 0 | <mask> app.logger.addHandler(StreamHandler(out))
<mask>
<mask> @app.route('/')
<mask> def index():
<mask> 1/0
<mask>
<mask> rv = app.test_client().get('/')
<mask> self.assert_equal(rv.status_code, 500)
<mask> self.assert_in(b'Internal Server Error',... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/helpers.py |
self.assert_in('1 // 0', err) | <mask>
<mask> err = out.getvalue()
<mask> self.assert_in('Exception on / [GET]', err)
<mask> self.assert_in('Traceback (most recent call last):', err)
<mask> self.assert_in('1/0', err)
<mask> self.assert_in('ZeroDivisionError:', err)
<mask>
<mask> def test_processor... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/helpers.py |
1 // 0 | <mask> app = flask.Flask(__name__)
<mask> @app.before_request
<mask> def before_request():
<mask> if trigger == 'before':
<mask> 1/0
<mask> @app.after_request
<mask> def after_request(response):
<mask> if trigger == 'after':
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/helpers.py |
1 // 0 | <mask> 1/0
<mask> @app.after_request
<mask> def after_request(response):
<mask> if trigger == 'after':
<mask> 1/0
<mask> return response
<mask> @app.route('/')
<mask> def index():
<mask> return 'Foo'
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/helpers.py |
1 // 0 | <mask> recorded = []
<mask>
<mask> @app.route('/')
<mask> def index():
<mask> 1/0
<mask>
<mask> def record(sender, exception):
<mask> recorded.append(exception)
<mask>
<mask> flask.got_request_exception.connect(record, app)
</s> replace 1/0 b... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/signals.py |
1 // 0 | <mask> app.logger.addHandler(StreamHandler(out))
<mask>
<mask> @app.route('/')
<mask> def index():
<mask> 1/0
<mask>
<mask> rv = app.test_client().get('/')
<mask> self.assert_equal(rv.status_code, 500)
<mask> self.assert_in(b'Internal Server Error',... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/subclassing.py |
1 // 0 | <mask> return 'Hello World!'
<mask>
<mask> @app.route('/other')
<mask> def other():
<mask> 1/0
<mask>
<mask> with app.test_client() as c:
<mask> resp = c.get('/')
<mask> self.assert_equal(flask.g.value, 42)
<mask> self.asser... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/testing.py |
1 // 0 | <mask> app = flask.Flask(__name__)
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> 1/0
<mask> def post(self):
<mask> 1/0
<mask>
<mask> class Other(Index):
<mask> def get(self):
</s> r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/views.py |
1 // 0 | <mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> 1/0
<mask> def post(self):
<mask> 1/0
<mask>
<mask> class Other(Index):
<mask> def get(self):
<mask> return 'GET'
<mask> def... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac04bc78361d5562f8289e8efe16a2e9a97b0d01 | flask/testsuite/views.py |
send_file, send_from_directory, get_flashed_messages, \
get_template_attribute | <mask>
<mask> from .app import Flask, Request, Response
<mask> from .config import Config
<mask> from .helpers import url_for, jsonify, json_available, flash, \
<mask> send_file, get_flashed_messages, get_template_attribute
<mask> from .globals import current_app, g, request, session, _request_ctx_stack
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac13deff401069c3854acca10c926119c6e1cbe0 | flask/__init__.py |
self.add_url_rule(self.static_path + '/<path:filename>', | <mask> self.url_map = Map()
<mask>
<mask> # if there is a static folder, register it for the application.
<mask> if self.has_static_folder:
<mask> self.add_url_rule(self.static_path + '/<filename>',
<mask> endpoint='static',
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac13deff401069c3854acca10c926119c6e1cbe0 | flask/app.py |
return send_from_directory(os.path.join(self.root_path, 'static'),
filename) | <mask> folder to the browser.
<mask>
<mask> .. versionadded:: 0.5
<mask> """
<mask> filename = posixpath.normpath(filename)
<mask> if filename.startswith(('/', '../')):
<mask> raise NotFound()
<mask> filename = os.path.join(self.root_path, 'static', f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac13deff401069c3854acca10c926119c6e1cbe0 | flask/helpers.py |
state.app.add_url_rule(path + '/<path:filename>', | <mask> if path is None:
<mask> path = state.app.static_path
<mask> if state.url_prefix:
<mask> path = state.url_prefix + path
<mask> state.app.add_url_rule(path + '/<filename>',
<mask> '%s.static' % module.name,
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac13deff401069c3854acca10c926119c6e1cbe0 | flask/module.py |
rv = c.get('/admin/static/css/test.css')
assert rv.data.strip() == '/* nested file */' | <mask> rv = c.get('/admin/')
<mask> assert rv.data == 'Hello from the Admin'
<mask> rv = c.get('/admin/static/test.txt')
<mask> assert rv.data.strip() == 'Admin File'
<mask>
<mask> with app.test_request_context():
<mask> assert flask.url_for('admin.static', fi... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ac13deff401069c3854acca10c926119c6e1cbe0 | tests/flask_tests.py |
``TRAP_BAD_REQUEST_ERRORS`` Werkzeug's internal data structures that | <mask> through the exception stack. This is
<mask> helpful for hairy debugging situations
<mask> where you have to find out where an HTTP
<mask> exception is coming from.
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/acac64e36a046cebae07bee7f3e8106b4a80288a | docs/config.rst |
bad request exceptions. Likewise many
operations can implicitly fail with a
BadRequest exception for consistency.
Since it's nice for debugging to know
... | <mask> exception is coming from.
<mask> ``TRAP_BAD_REQUEST_KEY_ERRORS`` Werkzeug's internal data structures that
<mask> deal with request specific data will
<mask> raise special key errors that are also
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/acac64e36a046cebae07bee7f3e8106b4a80288a | docs/config.rst |
``TRAP_BAD_REQUEST_ERRORS``, ``TRAP_HTTP_EXCEPTIONS`` | <mask> .. versionadded:: 0.7
<mask> ``PROPAGATE_EXCEPTIONS``, ``PRESERVE_CONTEXT_ON_EXCEPTION``
<mask>
<mask> .. versionadded:: 0.8
<mask> ``TRAP_BAD_REQUEST_KEY_ERRORS``, ``TRAP_HTTP_EXCEPTIONS``
<mask>
<mask> Configuring from Files
<mask> ----------------------
<mask>
<mask> Configuration becomes m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/acac64e36a046cebae07bee7f3e8106b4a80288a | docs/config.rst |
'TRAP_BAD_REQUEST_ERRORS': False, | <mask> 'USE_X_SENDFILE': False,
<mask> 'LOGGER_NAME': None,
<mask> 'SERVER_NAME': None,
<mask> 'MAX_CONTENT_LENGTH': None,
<mask> 'TRAP_BAD_REQUEST_KEY_ERRORS': False,
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/acac64e36a046cebae07bee7f3e8106b4a80288a | flask/app.py |
key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to `True`. It | <mask>
<mask> def trap_http_exception(self, e):
<mask> """Checks if an HTTP exception should be trapped or not. By default
<mask> this will return `False` for all exceptions except for a bad request
<mask> key error if ``TRAP_BAD_REQUEST_KEY_ERRORS`` is set to `True`. It
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/acac64e36a046cebae07bee7f3e8106b4a80288a | flask/app.py |
if self.config['TRAP_BAD_REQUEST_ERRORS']:
return isinstance(e, BadRequest) | <mask> .. versionadded:: 0.8
<mask> """
<mask> if self.config['TRAP_HTTP_EXCEPTIONS']:
<mask> return True
<mask> if self.config['TRAP_BAD_REQUEST_KEY_ERRORS']:
<mask> return isinstance(e, BadRequest) and isinstance(e, LookupError)
<mask> return Fals... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/acac64e36a046cebae07bee7f3e8106b4a80288a | flask/app.py |
app.config['TRAP_BAD_REQUEST_ERRORS'] = True | <mask> flask.request.form['missing_key']
<mask> c = app.test_client()
<mask> assert c.get('/fail').status_code == 400
<mask>
<mask> app.config['TRAP_BAD_REQUEST_KEY_ERRORS'] = True
<mask> c = app.test_client()
<mask> try:
<mask> c.get('/fail')
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/acac64e36a046cebae07bee7f3e8106b4a80288a | tests/flask_tests.py |
Note that the ``|tojson`` filter escapes forward slashes properly.
| <mask> </script>
<mask>
<mask> Template Rendering
<mask> ------------------
<mask>
<mask> .. autofunction:: render_template
</s> Fixed a security problem caused by changed simplejson semantics.
Notice: this was never in a release version of Flask. </s> remove self.jinja_env.filters['tojson... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ade490514dd6d83adc7610f69f9c4cd68df47110 | docs/api.rst |
escape slashes for you (``{{ "</script>"|tojson|safe }`` is rendered as
``"<\/script>"``). | <mask> In HTML the `script` tag is declared `CDATA` which means that entities
<mask> will not be parsed. Everything until ``</script>`` is handled as script.
<mask> This also means that there must never be any ``</`` between the script
<mask> tags. ``|tojson`` is kindly enough to do the right thing he... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ade490514dd6d83adc7610f69f9c4cd68df47110 | docs/patterns/jquery.rst |
def _tojson_filter(string, *args, **kwargs):
"""Calls dumps for the template engine, escaping Slashes properly."""
return json.dumps(string, *args, **kwargs).replace('/', '\\/')
| <mask> except (KeyError, AttributeError):
<mask> return os.getcwd()
<mask>
<mask>
<mask> class Flask(object):
<mask> """The flask object implements a WSGI application and acts as the central
<mask> object. It is passed the name of the module or package of the
<mask> application. Once... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ade490514dd6d83adc7610f69f9c4cd68df47110 | flask.py |
self.jinja_env.filters['tojson'] = _tojson_filter | <mask> url_for=url_for,
<mask> get_flashed_messages=get_flashed_messages
<mask> )
<mask> if json_available:
<mask> self.jinja_env.filters['tojson'] = json.dumps
<mask>
<mask> def create_jinja_loader(self):
<mask> """Creates the Jinja loader. By d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ade490514dd6d83adc7610f69f9c4cd68df47110 | flask.py |
def test_template_escaping(self):
app = flask.Flask(__name__)
with app.test_request_context():
rv = flask.render_template_string('{{ "</script>"|tojson|safe }}')
assert rv == '"<\\/script>"'
| <mask> assert rv.data == '3'
<mask>
<mask>
<mask> class TemplatingTestCase(unittest.TestCase):
<mask>
<mask> def test_context_processing(self):
<mask> app = flask.Flask(__name__)
<mask> @app.context_processor
</s> Fixed a security problem caused by changed simplejson semantics.
... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ade490514dd6d83adc7610f69f9c4cd68df47110 | tests/flask_tests.py |
sys.path.append(os.path.abspath('.')) | <mask> # add these directories to sys.path here. If the directory is relative to the
<mask> # documentation root, use os.path.abspath to make it absolute, like shown here.
<mask> sys.path.append(os.path.abspath('_themes'))
<mask>
<mask> # -- General configuration --------------------------------------------------... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae00f6d149c353e1ecb683ccbf01be221324a646 | docs/conf.py |
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
'flaskdocext'] | <mask> #needs_sphinx = '1.0'
<mask>
<mask> # Add any Sphinx extension module names here, as strings. They can be extensions
<mask> # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
<mask> extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']
<mask>
<mask> # Add any paths that contain tem... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae00f6d149c353e1ecb683ccbf01be221324a646 | docs/conf.py |
# Prepare the deferred setup of the logger. | <mask> #: exactly like a regular dictionary but supports additional methods
<mask> #: to load a config from files.
<mask> self.config = Config(self.root_path, self.default_config)
<mask>
<mask> #: Prepare the deferred setup of the logger.
<mask> self._logger = None
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae00f6d149c353e1ecb683ccbf01be221324a646 | flask/app.py |
:internal: | <mask> """Called before each request and will ensure that it triggers
<mask> the :attr:`before_first_request_funcs` and only exactly once per
<mask> application instance (which means process usually).
<mask>
<mask> .. versionadded:: 0.8
<mask> """
<mask> if self._... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae00f6d149c353e1ecb683ccbf01be221324a646 | flask/app.py |
super(SecureCookieSession, self).__init__(initial, on_update) | <mask> def __init__(self, initial=None):
<mask> def on_update(self):
<mask> self.modified = True
<mask> self.accessed = True
<mask> CallbackDict.__init__(self, initial, on_update)
<mask> self.modified = False
<mask> self.accessed = False
<mask>
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae133aa1734775f03560bde3d98c7f7d1c1569f7 | flask/sessions.py |
"""Used by session backends to determine if a ``Set-Cookie`` header
should be set for this session cookie for this response. If the session
has been modified, the cookie is set. If the session is permanent and
the ``SESSION_REFRESH_EACH_REQUEST`` config is true, the cookie is
alw... | <mask> if session.permanent:
<mask> return datetime.utcnow() + app.permanent_session_lifetime
<mask>
<mask> def should_set_cookie(self, app, session):
<mask> """Indicates whether a cookie should be set now or not. This is
<mask> used by session backends to figure out if t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae133aa1734775f03560bde3d98c7f7d1c1569f7 | flask/sessions.py |
return session.modified or (
session.permanent and app.config['SESSION_REFRESH_EACH_REQUEST']
) | <mask> This check is usually skipped if sessions get deleted.
<mask>
<mask> .. versionadded:: 0.11
<mask> """
<mask> if session.modified:
<mask> return True
<mask> save_each = app.config['SESSION_REFRESH_EACH_REQUEST']
<mask> return save_each and sess... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae133aa1734775f03560bde3d98c7f7d1c1569f7 | flask/sessions.py |
# If the session is modified to be empty, remove the cookie.
# If the session is empty, return without setting the cookie.
if not session:
if session.modified:
response.delete_cookie(
app.session_cookie_name,
domain=domain,
... | <mask> def save_session(self, app, session, response):
<mask> domain = self.get_cookie_domain(app)
<mask> path = self.get_cookie_path(app)
<mask>
<mask> if session.accessed:
<mask>
<mask> response.headers.add('Vary', 'Cookie')
<mask>
<mask> else:
<mask>
</s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae133aa1734775f03560bde3d98c7f7d1c1569f7 | flask/sessions.py |
# Add a "Vary: Cookie" header if the session was accessed at all.
if session.accessed: | <mask>
<mask> return
<mask>
<mask> response.headers.add('Vary', 'Cookie')
<mask>
<mask> if not self.should_set_cookie(app, session):
<mask> return
<mask>
</s> reorder session cookie checks to deleted, accessed, modified </s> remove else:
# De... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae133aa1734775f03560bde3d98c7f7d1c1569f7 | flask/sessions.py |
if not self.should_set_cookie(app, session):
return | <mask> if session.accessed:
<mask>
<mask> response.headers.add('Vary', 'Cookie')
<mask>
<mask> else:
<mask>
<mask> # Delete case. If there is no session we bail early.
<mask> # If the session was modified to be empty we remove the
<mask> # who... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep"... | https://github.com/pallets/flask/commit/ae133aa1734775f03560bde3d98c7f7d1c1569f7 | flask/sessions.py |
response.set_cookie(
app.session_cookie_name,
val,
expires=expires,
httponly=httponly,
domain=domain,
path=path,
secure=secure
) | <mask> httponly = self.get_cookie_httponly(app)
<mask> secure = self.get_cookie_secure(app)
<mask> expires = self.get_expiration_time(app, session)
<mask> val = self.get_signing_serializer(app).dumps(dict(session))
<mask> response.set_cookie(app.session_cookie_name, val,
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace"
] | https://github.com/pallets/flask/commit/ae133aa1734775f03560bde3d98c7f7d1c1569f7 | flask/sessions.py |
from inspect import getfullargspec as getargspec | <mask> iteritems = lambda d: iter(d.items())
<mask>
<mask> from io import StringIO
<mask>
<mask> def reraise(tp, value, tb=None):
<mask> if value.__traceback__ is not tb:
<mask> raise value.with_traceback(tb)
</s> Check if app factory takes script_info argument and call it with... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/_compat.py |
from inspect import getargspec | <mask> itervalues = lambda d: d.itervalues()
<mask> iteritems = lambda d: d.iteritems()
<mask>
<mask> from cStringIO import StringIO
<mask>
<mask> exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
<mask>
<mask> def implements_to_string(cls):
</s> Check if app factory takes s... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/_compat.py |
from ._compat import getargspec | <mask> from .globals import current_app
<mask> from .helpers import get_debug_flag
<mask>
<mask>
<mask> class NoAppException(click.UsageError):
<mask> """Raised if an application cannot be found or loaded."""
<mask>
<mask>
</s> Check if app factory takes script_info argument and call it with(out) scrip... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
def find_best_app(script_info, module): | <mask> class NoAppException(click.UsageError):
<mask> """Raised if an application cannot be found or loaded."""
<mask>
<mask>
<mask> def find_best_app(module):
<mask> """Given a module instance this tries to find the best possible
<mask> application in the module or raises an exception.
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
app = check_factory_for_script_info_and_call(app_factory,
script_info) | <mask> app_factory = getattr(module, attr_name, None)
<mask>
<mask> if callable(app_factory):
<mask> try:
<mask> app = app_factory()
<mask>
<mask> if isinstance(app, Flask):
<mask> return app
<mask> except TypeError:
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
def check_factory_for_script_info_and_call(func, script_info):
"""Given a function this checks if the function has an argument named
script_info or just a single argument and calls the function with
script_info if so. Otherwise calls the function without any arguments and
returns the result."""
a... | <mask> )
<mask>
<mask>
<mask> def prepare_exec_for_file(filename):
<mask> """Given a filename this will try to calculate the python path, add it
<mask> to the search path and return the actual module name that is expected.
<mask> """
<mask> module = []
<mask>
</s> Check if app factory t... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
def locate_app(script_info, app_id): | <mask> sys.path.insert(0, dirpath)
<mask> return '.'.join(module[::-1])
<mask>
<mask>
<mask> def locate_app(app_id):
<mask> """Attempts to locate the application."""
<mask> __traceback_hide__ = True
<mask> if ':' in app_id:
<mask> module, app_obj = app_id.split(':', 1)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
app = find_best_app(script_info, mod) | <mask> 'ensure the extension is .py' % module)
<mask>
<mask> mod = sys.modules[module]
<mask> if app_obj is None:
<mask> app = find_best_app(mod)
<mask> else:
<mask> app = getattr(mod, app_obj, None)
<mask> if app is None:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
rv = check_factory_for_script_info_and_call(self.create_app, self) | <mask> __traceback_hide__ = True
<mask> if self._loaded_app is not None:
<mask> return self._loaded_app
<mask> if self.create_app is not None:
<mask> rv = self.create_app(self)
<mask> else:
<mask> if not self.app_import_path:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
rv = locate_app(self, self.app_import_path) | <mask> 'Could not locate Flask application. You did not provide '
<mask> 'the FLASK_APP environment variable.\n\nFor more '
<mask> 'information see '
<mask> 'http://flask.pocoo.org/docs/latest/quickstart/')
<mask> rv = loca... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | flask/cli.py |
script_info = ScriptInfo() | <mask> def test_find_best_app(test_apps):
<mask> """Test if `find_best_app` behaves as expected with different combinations of input."""
<mask> class Module:
<mask> app = Flask('appname')
<mask> assert find_best_app(script_info, Module) == Module.app
<mask>
</s> Check if app factory takes sc... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
assert find_best_app(script_info, Module) == Module.app | <mask> def test_find_best_app(test_apps):
<mask> """Test if `find_best_app` behaves as expected with different combinations of input."""
<mask> class Module:
<mask> app = Flask('appname')
<mask> assert find_best_app(Module) == Module.app
<mask>
<mask> class Module:
<mask> applic... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
assert find_best_app(script_info, Module) == Module.application | <mask> assert find_best_app(Module) == Module.app
<mask>
<mask> class Module:
<mask> application = Flask('appname')
<mask> assert find_best_app(Module) == Module.application
<mask>
<mask> class Module:
<mask> myapp = Flask('appname')
<mask> assert find_best_app(Module) == ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
assert find_best_app(script_info, Module) == Module.myapp | <mask> assert find_best_app(Module) == Module.application
<mask>
<mask> class Module:
<mask> myapp = Flask('appname')
<mask> assert find_best_app(Module) == Module.myapp
<mask>
<mask> class Module:
<mask> @staticmethod
<mask> def create_app():
<mask> retur... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
assert isinstance(find_best_app(script_info, Module), Flask)
assert find_best_app(script_info, Module).name == 'appname'
class Module:
@staticmethod
def create_app(foo):
return Flask('appname')
assert isinstance(find_best_app(script_info, Module), Flask)
assert find_best... | <mask> class Module:
<mask> @staticmethod
<mask> def create_app():
<mask> return Flask('appname')
<mask> assert isinstance(find_best_app(Module), Flask)
<mask> assert find_best_app(Module).name == 'appname'
<mask>
<mask> class Module:
<mask> @staticmethod
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
assert isinstance(find_best_app(script_info, Module), Flask)
assert find_best_app(script_info, Module).name == 'appname' | <mask> class Module:
<mask> @staticmethod
<mask> def make_app():
<mask> return Flask('appname')
<mask> assert isinstance(find_best_app(Module), Flask)
<mask> assert find_best_app(Module).name == 'appname'
<mask>
<mask> class Module:
<mask> myapp = Flask('app... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
assert find_best_app(script_info, Module) == Module.myapp | <mask> myapp = Flask('appname1')
<mask> @staticmethod
<mask> def create_app():
<mask> return Flask('appname2')
<mask> assert find_best_app(Module) == Module.myapp
<mask>
<mask> class Module:
<mask> myapp = Flask('appname1')
<mask> @staticmethod
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
def create_app(): | <mask>
<mask> class Module:
<mask> myapp = Flask('appname1')
<mask> @staticmethod
<mask> def create_app(foo):
<mask> return Flask('appname2')
<mask> assert find_best_app(Module) == Module.myapp
<mask>
<mask> class Module:
<mask> pass
</s> Check if app... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
assert find_best_app(script_info, Module) == Module.myapp | <mask> myapp = Flask('appname1')
<mask> @staticmethod
<mask> def create_app(foo):
<mask> return Flask('appname2')
<mask> assert find_best_app(Module) == Module.myapp
<mask>
<mask> class Module:
<mask> pass
<mask> pytest.raises(NoAppException, find_best_a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
pytest.raises(NoAppException, find_best_app, script_info, Module) | <mask> assert find_best_app(Module) == Module.myapp
<mask>
<mask> class Module:
<mask> pass
<mask> pytest.raises(NoAppException, find_best_app, Module)
<mask>
<mask> class Module:
<mask> myapp1 = Flask('appname1')
<mask> myapp2 = Flask('appname2')
<mask> pytest.ra... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
pytest.raises(NoAppException, find_best_app, script_info, Module) | <mask>
<mask> class Module:
<mask> myapp1 = Flask('appname1')
<mask> myapp2 = Flask('appname2')
<mask> pytest.raises(NoAppException, find_best_app, Module)
<mask>
<mask> class Module:
<mask> @staticmethod
<mask> def create_app(foo):
<mask> return Flask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
def create_app(foo, bar): | <mask> pytest.raises(NoAppException, find_best_app, Module)
<mask>
<mask> class Module:
<mask> @staticmethod
<mask> def create_app(foo):
<mask> return Flask('appname2')
<mask> pytest.raises(NoAppException, find_best_app, Module)
<mask>
<mask>
<mask> def test_prepare_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
pytest.raises(NoAppException, find_best_app, script_info, Module) | <mask> class Module:
<mask> @staticmethod
<mask> def create_app(foo):
<mask> return Flask('appname2')
<mask> pytest.raises(NoAppException, find_best_app, Module)
<mask>
<mask>
<mask> def test_prepare_exec_for_file(test_apps):
<mask> """Expect the correct path to be set... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
script_info = ScriptInfo()
assert locate_app(script_info, "cliapp.app").name == "testapp"
assert locate_app(script_info, "cliapp.app:testapp").name == "testapp"
assert locate_app(script_info, "cliapp.multiapp:app1").name == "app1"
pytest.raises(NoAppException, locate_app,
script_in... | <mask>
<mask>
<mask> def test_locate_app(test_apps):
<mask> """Test of locate_app."""
<mask> assert locate_app("cliapp.app").name == "testapp"
<mask> assert locate_app("cliapp.app:testapp").name == "testapp"
<mask> assert locate_app("cliapp.multiapp:app1").name == "app1"
<mask> pytest.rais... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/ae41df9a77ceab4469029b043e38333b8654e1da | tests/test_cli.py |
<mask>
<mask> Here is an example of a configuration file::
<mask>
<mask> # Example configuration
<mask> DEBUG = False
<mask> SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/'
<mask>
<mask> Make sure to load the configuration very early on, so that extensions have
<mask> the ability to access the configuratio... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aec07a1cb59ec25765cc2f5c4b6011bccb989abc | docs/config.rst | |
<mask> An interesting pattern is also to use classes and inheritance for
<mask> configuration::
<mask>
<mask> class Config(object):
<mask> DEBUG = False
<mask> TESTING = False
<mask> DATABASE_URI = 'sqlite:///:memory:'
<mask>
<mask> class ProductionConfig(Config):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aec07a1cb59ec25765cc2f5c4b6011bccb989abc | docs/config.rst | |
pass | <mask> class ProductionConfig(Config):
<mask> DATABASE_URI = 'mysql://user@localhost/foo'
<mask>
<mask> class DevelopmentConfig(Config):
<mask> DEBUG = True
<mask>
<mask> class TestingConfig(Config):
<mask> TESTING = True
<mask>
<mask> To enable such a config you just ha... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aec07a1cb59ec25765cc2f5c4b6011bccb989abc | docs/config.rst |
<mask> your configuration classes::
<mask>
<mask> class Config(object):
<mask> """Base config, uses staging database server."""
<mask> DEBUG = False
<mask> TESTING = False
<mask> DB_SERVER = '192.168.1.56'
<mask>
<mask> @property
<mask> def DATABASE_URI(se... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aec07a1cb59ec25765cc2f5c4b6011bccb989abc | docs/config.rst | |
<mask> DB_SERVER = '192.168.19.32'
<mask>
<mask> class DevelopmentConfig(Config):
<mask> DB_SERVER = 'localhost'
<mask> DEBUG = True
<mask>
<mask> class TestingConfig(Config):
<mask> DB_SERVER = 'localhost'
<mask> DEBUG = True
<mask> DATABASE_URI = 'sq... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aec07a1cb59ec25765cc2f5c4b6011bccb989abc | docs/config.rst | |
<mask> DEBUG = True
<mask>
<mask> class TestingConfig(Config):
<mask> DB_SERVER = 'localhost'
<mask> DEBUG = True
<mask> DATABASE_URI = 'sqlite:///:memory:'
<mask>
<mask> There are many different ways and it's up to you how you want to manage
<mask> your configuration file... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/aec07a1cb59ec25765cc2f5c4b6011bccb989abc | docs/config.rst | |
def _method_route(
self,
method: str,
rule: str,
options: dict,
) -> t.Callable[[F], F]: | <mask> raise ValueError("Resources can only be opened for reading.")
<mask>
<mask> return open(os.path.join(self.root_path, resource), mode)
<mask>
<mask> def _method_route(self, method: str, rule: str, options: dict) -> t.Callable:
<mask> if "methods" in options:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
def get(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: | <mask> raise TypeError("Use the 'route' decorator to use the 'methods' argument.")
<mask>
<mask> return self.route(rule, methods=[method], **options)
<mask>
<mask> def get(self, rule: str, **options: t.Any) -> t.Callable:
<mask> """Shortcut for :meth:`route` with ``methods=["GET"... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
def post(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: | <mask> .. versionadded:: 2.0
<mask> """
<mask> return self._method_route("GET", rule, options)
<mask>
<mask> def post(self, rule: str, **options: t.Any) -> t.Callable:
<mask> """Shortcut for :meth:`route` with ``methods=["POST"]``.
<mask>
<mask> .. versionadded:: 2.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
def put(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: | <mask> .. versionadded:: 2.0
<mask> """
<mask> return self._method_route("POST", rule, options)
<mask>
<mask> def put(self, rule: str, **options: t.Any) -> t.Callable:
<mask> """Shortcut for :meth:`route` with ``methods=["PUT"]``.
<mask>
<mask> .. versionadded:: 2.0... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
def delete(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: | <mask> .. versionadded:: 2.0
<mask> """
<mask> return self._method_route("PUT", rule, options)
<mask>
<mask> def delete(self, rule: str, **options: t.Any) -> t.Callable:
<mask> """Shortcut for :meth:`route` with ``methods=["DELETE"]``.
<mask>
<mask> .. versionadded:... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
def patch(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: | <mask> .. versionadded:: 2.0
<mask> """
<mask> return self._method_route("DELETE", rule, options)
<mask>
<mask> def patch(self, rule: str, **options: t.Any) -> t.Callable:
<mask> """Shortcut for :meth:`route` with ``methods=["PATCH"]``.
<mask>
<mask> .. versionadded... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
def route(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: | <mask> .. versionadded:: 2.0
<mask> """
<mask> return self._method_route("PATCH", rule, options)
<mask>
<mask> def route(self, rule: str, **options: t.Any) -> t.Callable:
<mask> """Decorate a view function to register it with the given URL
<mask> rule and options. Cal... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
def decorator(f: F) -> F: | <mask> :param options: Extra options passed to the
<mask> :class:`~werkzeug.routing.Rule` object.
<mask> """
<mask>
<mask> def decorator(f: t.Callable) -> t.Callable:
<mask> endpoint = options.pop("endpoint", None)
<mask> self.add_url_rule(rule, endpoi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af34b8c9e7adbf0b060738fee12f04c1e46a98fd | src/flask/scaffold.py |
from ._compat import string_types, text_type, PY2 | <mask>
<mask> from .signals import message_flashed
<mask> from .globals import session, _request_ctx_stack, _app_ctx_stack, \
<mask> current_app, request
<mask> from ._compat import string_types, text_type
<mask>
<mask>
<mask> # sentinel
<mask> _missing = object()
<mask>
</s> Add last_modified arg f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af515cc7ea561292b07195c6a93662b7ca189e21 | flask/helpers.py |
cache_timeout=None, conditional=False, last_modified=None): | <mask>
<mask>
<mask> def send_file(filename_or_fp, mimetype=None, as_attachment=False,
<mask> attachment_filename=None, add_etags=True,
<mask> cache_timeout=None, conditional=False):
<mask> """Sends the contents of a file to the client. This will use the
<mask> most efficie... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af515cc7ea561292b07195c6a93662b7ca189e21 | flask/helpers.py |
:param last_modified: the Datetime object representing timestamp for when
the input file was last modified. | <mask> :param cache_timeout: the timeout in seconds for the headers. When ``None``
<mask> (default), this value is set by
<mask> :meth:`~Flask.get_send_file_max_age` of
<mask> :data:`~flask.current_app`.
<mask> """
<mask> mt... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af515cc7ea561292b07195c6a93662b7ca189e21 | flask/helpers.py |
if last_modified is not None:
if PY2:
rv.last_modified = int(last_modified.strftime("%s"))
else:
rv.last_modified = last_modified.timestamp()
elif mtime is not None: | <mask> direct_passthrough=True)
<mask>
<mask> # if we know the file modification date, we can store it as
<mask> # the time of the last modification.
<mask> if mtime is not None:
<mask> rv.last_modified = int(mtime)
<mask>
<mask> rv.cache_control.pub... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af515cc7ea561292b07195c6a93662b7ca189e21 | flask/helpers.py |
from flask._compat import StringIO, text_type, PY2 | <mask> from logging import StreamHandler
<mask> from werkzeug.exceptions import BadRequest, NotFound
<mask> from werkzeug.http import parse_cache_control_header, parse_options_header
<mask> from werkzeug.http import http_date
<mask> from flask._compat import StringIO, text_type
<mask>
<mask>
<mask> def has_en... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af515cc7ea561292b07195c6a93662b7ca189e21 | tests/test_helpers.py |
def test_send_file_last_modified(self):
app = flask.Flask(__name__)
with app.test_request_context():
dtm = datetime.datetime.now()
rv = flask.send_file('static/index.html', last_modified=dtm)
if PY2:
assert rv.last_modified == int(dtm.strftime("%s"... | <mask> rv.close()
<mask>
<mask> def test_send_file_object(self):
<mask> app = flask.Flask(__name__)
<mask>
<mask> with app.test_request_context():
<mask> with open(os.path.join(app.root_path, 'static/index.html'), mode='rb') as f:
</s> Add last_modified arg for send... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af515cc7ea561292b07195c6a93662b7ca189e21 | tests/test_helpers.py |
from flask._compat import StringIO, text_type, implements_iterator | <mask> import unittest
<mask> from logging import StreamHandler
<mask> from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr
<mask> from werkzeug.http import parse_cache_control_header, parse_options_header
<mask> from flask._compat import StringIO, text_type
<mask>
<mask>
<mask> def has_enc... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af5576a6c50ec849a824c1ace15f187d378db771 | flask/testsuite/helpers.py |
@implements_iterator | <mask> def test_streaming_with_context_and_custom_close(self):
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> called = []
<mask> class Wrapper(object):
<mask> def __init__(self, gen):
<mask> self._gen = gen
<mask> d... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af5576a6c50ec849a824c1ace15f187d378db771 | flask/testsuite/helpers.py |
def __next__(self): | <mask> def __iter__(self):
<mask> return self
<mask> def close(self):
<mask> called.append(42)
<mask> def next(self):
<mask> return next(self._gen)
<mask> @app.route('/')
<mask> def index():
<mask> d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/af5576a6c50ec849a824c1ace15f187d378db771 | flask/testsuite/helpers.py |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP hello
$ flask run
| <mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_APP=hello
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/cli.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask 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 ... | <mask> * Debugger PIN: 223-456-919
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/cli.rst |
.. group-tab:: Fish
.. code-block:: text
$ flask run --extra-files file1:dirA/file2:dirB/
# or
$ set -x FLASK_RUN_EXTRA_FILES file1 dirA/file2 dirB/
$ flask run
* Running on http://127.0.0.1:8000/
* Detected change in '/path/to/file1', reloading
| <mask> * Detected change in '/path/to/file1', reloading
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/cli.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_RUN_PORT 8000
$ flask run
* Running on http://127.0.0.1:8000/
| <mask> * Running on http://127.0.0.1:8000/
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_RUN_PORT=8000
<mask> > flask run
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/cli.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_SKIP_DOTENV 1
$ flask run
| <mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_SKIP_DOTENV=1
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/cli.rst |
.. group-tab:: Fish
Fish, :file:`venv/bin/activate.fish`::
$ set -x FLASK_APP hello
| <mask> Unix Bash, :file:`venv/bin/activate`::
<mask>
<mask> $ export FLASK_APP=hello
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> Windows CMD, :file:`venv\\Scripts\\activate.bat`::
<mask>
<mask> > set FLASK_APP=hello
<mask>
</s> Adding Fish commands to docs | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/cli.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run
| <mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/config.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x YOURAPPLICATION_SETTINGS /path/to/settings.cfg
$ flask run
* Running on http://127.0.0.1:5000/
| <mask> $ export YOURAPPLICATION_SETTINGS=/path/to/settings.cfg
<mask> $ flask run
<mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set YOURAPPLICATION_SETTINGS=\path\to\settings.cfg
<... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/config.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x SECRET_KEY "5f352379324c22463451387a0aec5d2f"
$ set -x MAIL_ENABLED false
$ flask run
* Running on http://127.0.0.1:5000/
| <mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/config.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run
| <mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_ENV=development
</s> Adding Fish commands to docs | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/debugging.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run --no-debugger --no-reload
| <mask>
<mask> $ export FLASK_ENV=development
<mask> $ flask run --no-debugger --no-reload
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_ENV=development
<mask> > flask run --no-debugger --no-reload
</s> Adding Fis... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/debugging.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP myapp
$ flask run
| <mask>
<mask> $ export FLASK_APP=myapp
<mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_APP=myapp
<mask> > flask run
</s> Adding Fish commands to docs | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/patterns/appfactories.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP "myapp:create_app('dev')"
$ flask run
| <mask>
<mask> $ export FLASK_APP="myapp:create_app('dev')"
<mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_APP="myapp:create_app('dev')"
<mask> > flask run
</s> Adding Fish commands to docs | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/patterns/appfactories.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP yourapplication
| <mask> .. code-block:: text
<mask>
<mask> $ export FLASK_APP=yourapplication
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
</s> Adding Fish commands to docs | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/patterns/packages.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
| <mask> $ export FLASK_ENV=development
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_ENV=development
<mask>
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/patterns/packages.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP hello
$ flask run
* Running on http://127.0.0.1:5000/
| <mask> $ export FLASK_APP=hello
<mask> $ flask run
<mask> * Running on http://127.0.0.1:5000/
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_APP=hello
<mask> > flask run
</s> Adding Fish commands to docs | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/quickstart.rst |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.