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
elif isinstance(rv, dict): rv = jsonify(rv)
<mask> # waiting to do it manually, so that the class can handle any <mask> # special logic <mask> rv = self.response_class(rv, status=status, headers=headers) <mask> status = headers = None <mask> else: <mask> # evaluate ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7bf8366970ec49b5396a1f86f00fdd1c5fef3fed
flask/app.py
rv = client.get('/dict') assert rv.json == {"foo": "bar"} assert rv.status_code == 201
<mask> assert b"Not Found" in rv.data <mask> assert rv.status_code == 404 <mask> <mask> <mask> def test_response_type_errors(): <mask> app = flask.Flask(__name__) <mask> app.testing = True </s> Allow dictionary return values as JSON This supports an increasingly common usecase whereby JSON is...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7bf8366970ec49b5396a1f86f00fdd1c5fef3fed
tests/test_basic.py
server) you might not see any log messages. The reason for that is that Flask by default will just report to the WSGI error stream or stderr (depending on what's available). Where this ends up is sometimes hard to find. Often it's in your webserver's log files. I can pretty much promise you however that if you only...
<mask> Error Mails <mask> ----------- <mask> <mask> If the application runs in production mode (which it will do on your <mask> server) you won't see any log messages by default. Why is that? Flask <mask> tries to be a zero-configuration framework. Where should it drop the logs <mask> for you if there is no ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
docs/errorhandling.rst
debug a problem. By default as of Flask 1.0, errors are logged to your webserver's log automatically. Warnings however are not. Please note that Flask itself will not issue any warnings in the core system, so it's your responsibility to warn in the code if something seems odd.
<mask> ----------------- <mask> <mask> Even if you get mails, you probably also want to log warnings. It's a <mask> good idea to keep as much information around that might be required to <mask> debug a problem. Please note that Flask itself will not issue any <mask> warnings in the core system, so it's your re...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
docs/errorhandling.rst
import sys from werkzeug.local import LocalProxy
<mask> from __future__ import absolute_import <mask> <mask> from logging import getLogger, StreamHandler, Formatter, getLoggerClass, \ <mask> DEBUG, ERROR <mask> from .globals import _request_ctx_stack <mask> <mask> </s> Updated the logging documentation for recent changes. </s> remove prod_handler ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
flask/logging.py
from .globals import _request_ctx_stack
<mask> from logging import getLogger, StreamHandler, Formatter, getLoggerClass, \ <mask> DEBUG, ERROR <mask> <mask> <mask> PROD_LOG_FORMAT = '[%(asctime)s] %(levelname)s in %(module)s: %(message)s' <mask> DEBUG_LOG_FORMAT = ( <mask> '-' * 80 + '\n' + <mask> '%(levelname)s in %(module)s [%(pathnam...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
flask/logging.py
@LocalProxy def _proxy_stream(): """Finds the most appropriate error stream for the application. If a WSGI request is in flight we log to wsgi.errors, otherwise this resolves to sys.stderr. """ ctx = _request_ctx_stack.top if ctx is not None: return ctx.request.environ['wsgi.errors'] ...
<mask> '-' * 80 <mask> ) <mask> <mask> <mask> def should_log_for(app, mode): <mask> policy = app.config['LOGGER_HANDLER_POLICY'] <mask> if policy == mode or policy == 'always': <mask> return True <mask> return False <mask> </s> Updated the logging documentation for recent changes. ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
flask/logging.py
if app.debug and _should_log_for(app, 'debug'):
<mask> return Logger.getEffectiveLevel(x) <mask> <mask> class DebugHandler(StreamHandler): <mask> def emit(self, record): <mask> if app.debug and should_log_for(app, 'debug'): <mask> StreamHandler.emit(self, record) <mask> <mask> class ProductionHandler(...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
flask/logging.py
if not app.debug and _should_log_for(app, 'production'):
<mask> StreamHandler.emit(self, record) <mask> <mask> class ProductionHandler(StreamHandler): <mask> def emit(self, record): <mask> if not app.debug and should_log_for(app, 'production'): <mask> StreamHandler.emit(self, record) <mask> <mask> debug_ha...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
flask/logging.py
prod_handler = ProductionHandler(_proxy_stream)
<mask> debug_handler = DebugHandler() <mask> debug_handler.setLevel(DEBUG) <mask> debug_handler.setFormatter(Formatter(DEBUG_LOG_FORMAT)) <mask> <mask> prod_handler = ProductionHandler() <mask> prod_handler.setLevel(ERROR) <mask> prod_handler.setFormatter(Formatter(PROD_LOG_FORMAT)) <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c16054d81ce9af44a4875650b506c9ec2403588
flask/logging.py
:param last_modified: set the ``Last-Modified`` header to this value, a :class:`~datetime.datetime` or timestamp. If a file was passed, this overrides its mtime.
<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> :param last_modifi...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c271401b284e6fcc2040fffe317342e2a17a902
flask/helpers.py
<mask> <mask> rv = current_app.response_class(data, mimetype=mimetype, headers=headers, <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 last_modifi...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c271401b284e6fcc2040fffe317342e2a17a902
flask/helpers.py
rv.last_modified = last_modified
<mask> <mask> # if we know the file modification date, we can store it as <mask> # the time of the last modification. <mask> if last_modified is not None: <mask> if PY2: <mask> rv.last_modified = int(last_modified.strftime("%s")) <mask> else: <mask> rv.last_m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c271401b284e6fcc2040fffe317342e2a17a902
flask/helpers.py
rv.last_modified = mtime
<mask> rv.last_modified = int(last_modified.strftime("%s")) <mask> else: <mask> rv.last_modified = last_modified.timestamp() <mask> elif mtime is not None: <mask> rv.last_modified = int(mtime) <mask> <mask> rv.cache_control.public = True <mask> if cache_timeo...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c271401b284e6fcc2040fffe317342e2a17a902
flask/helpers.py
last_modified = datetime.datetime(1999, 1, 1) @app.route('/') def index(): return flask.send_file(StringIO("party like it's"), last_modified=last_modified) c = app.test_client() rv = c.get('/') assert rv.last_modified == last_modified
<mask> rv.close() <mask> <mask> def test_send_file_last_modified(self): <mask> app = flask.Flask(__name__) <mask> with app.test_request_context(): <mask> dtm = datetime.datetime.now() <mask> rv = flask.send_file('static/index.html', last_modified=dtm) <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c271401b284e6fcc2040fffe317342e2a17a902
tests/test_helpers.py
if sys.path[0] != dirpath: sys.path.insert(0, dirpath)
<mask> module.append(extra) <mask> if not os.path.isfile(os.path.join(dirpath, '__init__.py')): <mask> break <mask> <mask> sys.path.insert(0, dirpath) <mask> return '.'.join(module[::-1]) <mask> <mask> <mask> def locate_app(script_info, app_id): <mask> """Attempts to...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
flask/cli.py
def locate_app(script_info, app_id, raise_if_not_found=True):
<mask> sys.path.insert(0, dirpath) <mask> return '.'.join(module[::-1]) <mask> <mask> <mask> def locate_app(script_info, 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...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
flask/cli.py
' the app (%s):\n%s' % (module, stack_trace)) elif raise_if_not_found:
<mask> # Determine this by checking whether the trace has a depth > 1. <mask> if sys.exc_info()[-1].tb_next: <mask> stack_trace = traceback.format_exc() <mask> raise NoAppException('There was an error trying to import' <mask> ' the app (%s):\n%s' % (modul...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
flask/cli.py
else: return
<mask> ' to exist. Please verify the path is ' <mask> 'correct. If app is not on PYTHONPATH, ' <mask> 'ensure the extension is .py' % module) <mask> <mask> mod = sys.modules[module] <mask> if app_obj is N...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
flask/cli.py
if self.app_import_path: rv = locate_app(self, self.app_import_path) else: for module in ['wsgi.py', 'app.py']: import_path = prepare_exec_for_file(module) rv = locate_app(self, import_path, ...
<mask> <mask> if self.create_app is not None: <mask> rv = call_factory(self.create_app, self) <mask> else: <mask> if not self.app_import_path: <mask> raise NoAppException( <mask> 'Could not locate Flask application. You did not provide ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
flask/cli.py
'the FLASK_APP environment variable, and a wsgi.py or ' 'app.py module was not found in the current directory.\n\n' 'For more information see '
<mask> else: <mask> if not self.app_import_path: <mask> raise NoAppException( <mask> 'Could not locate Flask application. You did not provide ' <mask> 'the FLASK_APP environment variable.\n\nFor more ' <mask> 'informat...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
flask/cli.py
<mask> 'the FLASK_APP environment variable.\n\nFor more ' <mask> 'information see ' <mask> 'http://flask.pocoo.org/docs/latest/quickstart/') <mask> <mask> rv = locate_app(self, self.app_import_path) <mask> <mask> debug = get_debug_...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
flask/cli.py
assert locate_app(script_info, "notanpp.py", raise_if_not_found=False) is None
<mask> pytest.raises( <mask> NoAppException, locate_app, script_info, "cliapp.importerrorapp") <mask> <mask> <mask> def test_find_default_import_path(test_apps, monkeypatch, tmpdir): <mask> """Test of find_default_import_path.""" <mask> monkeypatch.delitem(os.environ, 'FLASK_APP', raising=F...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
tests/test_cli.py
def test_scriptinfo(test_apps, monkeypatch):
<mask> assert flask_ver in out <mask> assert py_ver in out <mask> <mask> <mask> def test_scriptinfo(test_apps): <mask> """Test of ScriptInfo.""" <mask> obj = ScriptInfo(app_import_path="cliapp.app:testapp") <mask> assert obj.load_app().name == "testapp" <mask> assert obj.load_app().na...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c40aa9e50d97b7c412745a53c8cdc2597c46680
tests/test_cli.py
- Show an error when a blueprint name contains a dot. The ``.`` has special meaning, it is used to separate (nested) blueprint names and the endpoint name. :issue:`4041`
<mask> - Fix some types that weren't available in Python 3.6.0. :issue:`4040` <mask> - Improve typing for ``send_file``, ``send_from_directory``, and <mask> ``get_send_file_max_age``. :issue:`4044`, :pr:`4026` <mask> <mask> <mask> Version 2.0.0 <mask> ------------- <mask> </s> blueprint name may not...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
CHANGES.rst
if "." in name: raise ValueError("'name' may not contain a dot '.' character.")
<mask> template_folder=template_folder, <mask> root_path=root_path, <mask> ) <mask> self.name = name <mask> self.url_prefix = url_prefix <mask> self.subdomain = subdomain <mask> self.deferred_functions: t.List[DeferredSetupFunction] = [] <mask> <...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
src/flask/blueprints.py
if endpoint and "." in endpoint: raise ValueError("'endpoint' may not contain a dot '.' character.") if view_func and hasattr(view_func, "__name__") and "." in view_func.__name__: raise ValueError("'view_func' name may not contain a dot '.' character.")
<mask> ) -> None: <mask> """Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for <mask> the :func:`url_for` function is prefixed with the name of the blueprint. <mask> """ <mask> if endpoint: <mask> assert "." not in endpoint, "Blueprint endpoints ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
src/flask/blueprints.py
bp = flask.Blueprint("foo", __name__, template_folder="template")
<mask> assert client.get("/foo").data == b"/en/about" <mask> <mask> <mask> def test_inject_blueprint_url_defaults(app): <mask> bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template") <mask> <mask> @bp.url_defaults <mask> def bp_defaults(endpoint, values): <mask> val...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_basic.py
app.inject_url_defaults("foo.view", values)
<mask> <mask> app.register_blueprint(bp) <mask> <mask> values = dict() <mask> app.inject_url_defaults("foo.bar.baz.view", values) <mask> expected = dict(page="login") <mask> assert values == expected <mask> <mask> with app.test_request_context("/somepage"): <mask> url = flas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_basic.py
url = flask.url_for("foo.view")
<mask> expected = dict(page="login") <mask> assert values == expected <mask> <mask> with app.test_request_context("/somepage"): <mask> url = flask.url_for("foo.bar.baz.view") <mask> expected = "/login" <mask> assert url == expected <mask> <mask> <mask> def test_nonascii_pathinfo...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_basic.py
<mask> import functools <mask> <mask> import pytest <mask> from jinja2 import TemplateNotFound <mask> from werkzeug.http import parse_cache_control_header <mask> <mask> import flask </s> blueprint name may not contain a dot </s> remove assert client.get("/py/foo").data == b"bp.foo" # The rule's didn't...
[ "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_blueprints.py
def test_dotted_name_not_allowed(app, client): with pytest.raises(ValueError): flask.Blueprint("app.ui", __name__)
<mask> templates = sorted(app.jinja_env.list_templates()) <mask> assert templates == ["admin/index.html", "frontend/index.html"] <mask> <mask> <mask> def test_dotted_names(app, client): <mask> frontend = flask.Blueprint("myapp.frontend", __name__) <mask> backend = flask.Blueprint("myapp.backend...
[ "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/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_blueprints.py
with pytest.raises(ValueError): bp.route("/", endpoint="a.b")(lambda: "")
<mask> <mask> def test_route_decorator_custom_endpoint_with_dots(app, client): <mask> bp = flask.Blueprint("bp", __name__) <mask> <mask> @bp.route("/foo") <mask> def foo(): <mask> return flask.request.endpoint <mask> <mask> try: <mask> <mask> @bp.route("/bar", endpoint="ba...
[ "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/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_blueprints.py
with pytest.raises(ValueError): bp.add_url_rule("/", endpoint="a.b")
<mask> ) <mask> <mask> foo_foo_foo.__name__ = "bar.123" <mask> <mask> pytest.raises( <mask> AssertionError, lambda: bp.add_url_rule("/bar/123", view_func=foo_foo_foo) <mask> ) <mask> <mask> bp.add_url_rule( <mask> "/bar/456", endpoint="foofoofoo", view_func=functools.par...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_blueprints.py
def view(): return ""
<mask> pytest.raises( <mask> AssertionError, lambda: bp.add_url_rule("/bar/123", view_func=foo_foo_foo) <mask> ) <mask> <mask> bp.add_url_rule( <mask> "/bar/456", endpoint="foofoofoo", view_func=functools.partial(foo_foo_foo) <mask> ) <mask> <mask> app.register_blueprint(b...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_blueprints.py
view.__name__ = "a.b"
<mask> bp.add_url_rule( <mask> "/bar/456", endpoint="foofoofoo", view_func=functools.partial(foo_foo_foo) <mask> ) <mask> <mask> app.register_blueprint(bp, url_prefix="/py") <mask> <mask> assert client.get("/py/foo").data == b"bp.foo" <mask> # The rule's didn't actually made it thr...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_blueprints.py
with pytest.raises(ValueError): bp.add_url_rule("/", view_func=view)
<mask> ) <mask> <mask> app.register_blueprint(bp, url_prefix="/py") <mask> <mask> assert client.get("/py/foo").data == b"bp.foo" <mask> # The rule's didn't actually made it through <mask> rv = client.get("/py/bar") <mask> assert rv.status_code == 404 <mask> rv = client.get("/py/ba...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c5261407dae61679c268b44c63d73909c3fe652
tests/test_blueprints.py
Thread-Locals in Flask ----------------------
<mask> Foreword for Experienced Programmers <mask> ==================================== <mask> <mask> This chapter is for programmers who have worked with other frameworks in the <mask> past, and who may have more specific or esoteric concerns that the typical <mask> user. <mask> <mask> Threads in Flask <mas...
[ "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/advanced_foreword.rst
problems of modern web applications: cross-site scripting (XSS). Unless you deliberately mark insecure HTML as secure, Flask and the underlying Jinja2 template engine have you covered. But there are many more ways to cause security problems.
<mask> you still want that data to be stored securely. <mask> <mask> Unfortunately, there are many ways the security of a web application can be <mask> compromised. Flask protects you against one of the most common security <mask> problems of modern web applications: cross-site scripting (XSS). Unless <mask> y...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/advanced_foreword.rst
The documentation will warn you about aspects of web development that require attention to security. Some of these security concerns are far more complex than one might think, and we all sometimes underestimate the likelihood that a vulnerability will be exploited - until a clever attacker figures out a way to exploit...
<mask> you deliberately mark insecure HTML as secure, Flask and the underlying <mask> Jinja2 template engine have you covered. But there are many more ways to <mask> cause security problems. <mask> <mask> The documentation will warn you about aspects of web development that <mask> require attention to security....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/advanced_foreword.rst
Flask is no different from any other framework in that you the developer must build with caution, watching for exploits when building to your requirements.
<mask> Depending on the kind of attack, chances are that automated bots are <mask> probing for ways to fill your database with spam, links to malicious <mask> software, and the like. <mask> <mask> So always keep security in mind when doing web development. <mask> <mask> The Status of Python 3 <mask> ---------...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/advanced_foreword.rst
Continue to :ref:`installation` or the :ref:`quickstart`.
<mask> using Python 2.6 and 2.7 with activated Python 3 warnings during <mask> development. If you plan on upgrading to Python 3 in the near future we <mask> strongly recommend that you read `How to write forwards compatible <mask> Python code <http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/>`_. </s...
[ "keep", "keep", "keep", "add" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/advanced_foreword.rst
Here are your options when growing your codebase or scaling your application. Read the Source. ---------------- Flask started in part to demonstrate how to build your own framework on top of existing well-used tools Werkzeug (WSGI) and Jinja (templating), and as it developed, it became useful to a wide audience. As ...
<mask> <mask> Becoming Big <mask> ============ <mask> <mask> Your application is becoming more and more complex? If you suddenly <mask> realize that Flask does things in a way that does not work out for your <mask> application there are ways to deal with that. <mask> <mask> Flask is powered by Werkzeug and...
[ "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/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/becomingbig.rst
The :ref:`app-dispatch` chapter shows in detail how to apply middleware. You can introduce WSGI middleware to wrap your Flask instances and introduce fixes and changes at the layer between your Flask application and your HTTP server. Werkzeug includes several `middlewares <http://werkzeug.pocoo.org/docs/middlewares/>`_...
<mask> <mask> Why consider Forking? <mask> --------------------- <mask> <mask> The majority of code of Flask is within Werkzeug and Jinja2. These <mask> libraries do the majority of the work. Flask is just the paste that glues <mask> those together. For every project there is the point where the underlying ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/becomingbig.rst
Scale like a pro. -----------------
<mask> Furthermore integrating upstream changes can be a complex process, <mask> depending on the number of changes. Because of that, forking should be <mask> the very last resort. <mask> <mask> Scaling like a Pro <mask> ------------------ <mask> <mask> For many web applications the complexity of the code is...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/becomingbig.rst
Discuss with the community.
<mask> majority of servers are using either threads, greenlets or separate <mask> processes to achieve concurrency which are all methods well supported by <mask> the underlying Werkzeug library. <mask> <mask> Dialogue with the Community <mask> --------------------------- <mask> <mask> The Flask developers are...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/becomingbig.rst
The Flask developers keep the framework accessible to users with codebases big and small. If you find an obstacle in your way, caused by Flask, don't hesitate to contact the developers on the mailinglist or IRC channel. The best way for the Flask and Flask extension developers to improve the tools for larger
<mask> <mask> Dialogue with the Community <mask> --------------------------- <mask> <mask> The Flask developers are very interested to keep everybody happy, so as <mask> soon as you find an obstacle in your way, caused by Flask, don't hesitate <mask> to contact the developers on the mailinglist or IRC channel....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/becomingbig.rst
advanced_foreword
<mask> .. toctree:: <mask> :maxdepth: 2 <mask> <mask> foreword <mask> installation <mask> quickstart <mask> tutorial/index <mask> templating <mask> testing <mask> errorhandling </s> Revise foreword and Becoming Big docs, #484. </s> remove Flask is based on convention over configurati...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/contents.rst.inc
handle that. Instead, Flask supports extensions to add such functionality to your application as if it was implemented in Flask itself. Numerous extensions
<mask> and nothing you don't. <mask> <mask> By default, Flask does not include a database abstraction layer, form <mask> validation or anything else where different libraries already exist that can <mask> handle that. Instead, FLask extensions add such functionality to your <mask> application as if it was implem...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/foreword.rst
authentication technologies, and more. Flask may be "micro", but it's ready for production use on a variety of needs.
<mask> validation or anything else where different libraries already exist that can <mask> handle that. Instead, FLask extensions add such functionality to your <mask> application as if it was implemented in Flask itself. Numerous extensions <mask> provide database integration, form validation, upload handling, var...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/foreword.rst
Configuration and Conventions
<mask> provide database integration, form validation, upload handling, various open <mask> authentication technologies, and more. Flask may be "micro", but the <mask> possibilities are endless. <mask> <mask> Convention over Configuration <mask> ----------------------------- <mask> <mask> Flask is based on con...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/foreword.rst
Flask has many configuration values, with sensible defaults, and a few conventions when getting started. By convention templates and static files are stored in subdirectories within the application's Python source tree, with the names `templates` and `static` respectively. While this can be changed you usually don't h...
<mask> <mask> Convention over Configuration <mask> ----------------------------- <mask> <mask> Flask is based on convention over configuration, which means that many things <mask> are preconfigured. For example, by convention templates and static files are <mask> stored in subdirectories within the application...
[ "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/7c79ce6e418f07a49be8c25a4c5a40e5347be257
docs/foreword.rst
many things are preconfigured. For example, by convention templates and static files are stored in subdirectories within the application's Python source tree. While this can be changed you usually don't have to.
<mask> and provide you with a lot of tools to make it as pleasant as possible to <mask> work with them. <mask> <mask> Flask is also based on convention over configuration, which means that <mask> many things are preconfigured. For example, by convention, templates and <mask> static files are in subdirectories w...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/foreword.rst
The main reason Flask is called a "microframework" is the idea
<mask> many things are preconfigured. For example, by convention, templates and <mask> static files are in subdirectories within the Python source tree of the <mask> application. While this can be changed you usually don't have to. <mask> <mask> The main reason however why Flask is called a "microframework" is ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/foreword.rst
already exist that can handle that. However Flask supports extensions to add such functionality to your application as if it
<mask> <mask> The main reason however why Flask is called a "microframework" is the idea <mask> to keep the core simple but extensible. There is no database abstraction <mask> layer, no form validation or anything else where different libraries <mask> already exist that can handle that. However Flask knows the ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/foreword.rst
object-relational mappers, form validation, upload handling, various open
<mask> layer, no form validation or anything else where different libraries <mask> already exist that can handle that. However Flask knows the concept of <mask> extensions that can add this functionality into your application as if it <mask> was implemented in Flask itself. There are currently extensions for <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/foreword.rst
the likelihood that a vulnerability will be exploited - until a clever
<mask> <mask> The documentation will warn you about aspects of web development that <mask> require attention to security. Some of these security concerns <mask> are far more complex than one might think, and we all sometimes underestimate <mask> the likelihood that a vulnerability will be exploited, until a clev...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/foreword.rst
long, partially also because we have not quite worked out how the lower- level API should change to account for the Unicode differences in Python 3.
<mask> support the new iteration of the Python programming language. While the <mask> situation is greatly improving there are still some issues that make it <mask> hard for us to switch over to Python 3 just now. These problems are <mask> partially caused by changes in the language that went unreviewed for too ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/foreword.rst
So how do you get all that on your computer quickly? There are many ways, as this section will explain, but the most kick-ass method is
<mask> Werkzeug is a toolkit for WSGI, the standard Python interface between web <mask> applications and a variety of servers for both development and deployment. <mask> Jinja2 renders templates. <mask> <mask> So how do you get all that on your computer quickly? There are many ways <mask> which this section wil...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/installation.rst
information on how to do that. Once you have it installed, run the
<mask> $ sudo apt-get install python-virtualenv <mask> <mask> If you are on Windows and don't have the `easy_install` command, you must <mask> install it first. Check the :ref:`windows-easy-install` section for more <mask> information about how to do that. Once you have it installed, run the <mask> same co...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/installation.rst
does not work in your shell, try replacing the dot with ``source``.)
<mask> $ . env/bin/activate <mask> <mask> (Note the space between the dot and the script name. The dot means that <mask> this script should run in the context of the current shell. If this command <mask> does not work in your shell, try replacing the dot with ``source``) <mask> <mask> If you are a Window...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/installation.rst
System-Wide Installation
<mask> <mask> A few seconds later you are good to go. <mask> <mask> <mask> System Wide Installation <mask> ------------------------ <mask> <mask> This is possible as well, but I do not recommend it. Just run <mask> `easy_install` with root rights:: <mask> </s> Fixed various stylistic issues in document...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/installation.rst
This is possible as well, though I do not recommend it. Just run `easy_install` with root privileges::
<mask> <mask> System Wide Installation <mask> ------------------------ <mask> <mask> This is possible as well, but I do not recommend it. Just run <mask> `easy_install` with root rights:: <mask> <mask> $ sudo easy_install Flask <mask> <mask> (Run it in an Admin shell on Windows systems and without `s...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/installation.rst
(Run it in an Admin shell on Windows systems and without `sudo`.)
<mask> `easy_install` with root rights:: <mask> <mask> $ sudo easy_install Flask <mask> <mask> (Run it in an Admin shell on Windows systems and without `sudo`). <mask> <mask> <mask> Living on the Edge <mask> ------------------ <mask> </s> Fixed various stylistic issues in documentation </s> remove T...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/installation.rst
on the "Environment variables" button and double-click on the "Path"
<mask> to the `PATH` environment variable. To do that, right-click on the <mask> "Computer" icon on the Desktop or in the Start menu, and choose <mask> "Properties". Then, on Windows Vista and Windows 7 click on "Advanced System <mask> settings"; on Windows XP, click on the "Advanced" tab instead. Then click <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/installation.rst
Eager to get started? This page gives a good introduction on how to get
<mask> <mask> Quickstart <mask> ========== <mask> <mask> Eager to get started? This page gives a good introduction in how to get <mask> started with Flask. This assumes you already have Flask installed. If <mask> you do not, head over to the :ref:`installation` section. <mask> <mask> <mask> A Minimal A...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
the application's module. If you are using a single module (as in this example) you should use `__name__` because depending on whether it's started as
<mask> So what did that code do? <mask> <mask> 1. First we imported the :class:`~flask.Flask` class. An instance of this <mask> class will be our WSGI application. The first argument is the name of <mask> the application's module. If you are using a single module (like here) <mask> you should use `__...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
on this technique, have a look at the :class:`~flask.Flask` documentation.
<mask> the application's module. If you are using a single module (like here) <mask> you should use `__name__` because depending on if it's started as <mask> application or imported as module the name will be different <mask> (``'__main__'`` versus the actual import name). For more information <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
which URL should trigger our function.
<mask> 2. Next we create an instance of it. We pass it the name of the module / <mask> package. This is needed so that Flask knows where it should look for <mask> templates, static files and so on. <mask> 3. Then we use the :meth:`~flask.Flask.route` decorator to tell Flask <mask> what URL should trigge...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
If you run the server you will notice that the server is only accessible
<mask> .. _public-server: <mask> <mask> .. admonition:: Externally Visible Server <mask> <mask> If you run the server you will notice that the server is only available <mask> from your own computer, not from any other in the network. This is the <mask> default because in debugging mode a user of the ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
arbitrary Python code on your computer.
<mask> <mask> If you run the server you will notice that the server is only available <mask> from your own computer, not from any other in the network. This is the <mask> default because in debugging mode a user of the application can execute <mask> arbitrary Python code on your computer. If you hav...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
If you have `debug` disabled or trust the users on your network, you can make the server publicly available simply by changing the call of the :meth:`~flask.Flask.run` method to look like this::
<mask> arbitrary Python code on your computer. If you have `debug` disabled <mask> or trust the users on your network, you can make the server publicly <mask> available. <mask> <mask> Just change the call of the :meth:`~flask.Flask.run` method to look <mask> like this:: <mask> <mask> ap...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
change to your code. That is not very nice and Flask can do better. If you enable debug support the server will reload itself on code changes, and it will also provide you with a helpful debugger if things go wrong.
<mask> ---------- <mask> <mask> The :meth:`~flask.Flask.run` method is nice to start a local <mask> development server, but you would have to restart it manually after each <mask> change you do to code. That is not very nice and Flask can do better. If <mask> you enable the debug support the server will reload...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
Or pass it to `run`::
<mask> <mask> app.debug = True <mask> app.run() <mask> <mask> Or pass it to run:: <mask> <mask> app.run(debug=True) <mask> <mask> Both will have exactly the same effect. <mask> </s> Fixed various stylistic issues in documentation </s> remove change you do to code. That is not very nice and ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
the URLs, which is especially handy for applications that are used from
<mask> Routing <mask> ------- <mask> <mask> Modern web applications have beautiful URLs. This helps people remember <mask> the URLs which is especially handy for applications that are used from <mask> mobile devices with slower network connections. If the user can directly <mask> go to the desired page withou...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
behind that module is to ensure nice-looking and also unique URLs based on behaviour coined by Apache and earlier servers.
<mask> <mask> .. admonition:: Unique URLs / Redirection Behaviour <mask> <mask> Flask's URL rules are based on Werkzeug's routing module. The idea <mask> behind that module is to ensure nice looking and also unique URLs based <mask> on behaviour Apache and earlier servers coined. <mask> <mask> T...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
However, in the second case the URL is defined without a slash so it
<mask> `projects` endpoint has a trailing slash. It's similar to a folder in <mask> that sense. Accessing it without a trailing slash will cause Flask to <mask> redirect to the canonical URL with the trailing slash. <mask> <mask> However in the second case the URL is defined without a slash so it <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
will result in a 404 error.
<mask> redirect to the canonical URL with the trailing slash. <mask> <mask> However in the second case the URL is defined without a slash so it <mask> behaves similar to a file and accessing the URL with a trailing slash <mask> will be a 404 error. <mask> <mask> Why is this? This allows relativ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
will stay unique which ensures search engines do not index the same page
<mask> <mask> Why is this? This allows relative URLs to continue working if users <mask> access the page when they forget a trailing slash. This behaviour is <mask> also consistent with how Apache and other servers work. Also, the URLs <mask> will stay unique which helps search engines not indexing...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
Have a look at the explanation below: :ref:`context-locals`.)
<mask> <mask> (This also uses the :meth:`~flask.Flask.test_request_context` method <mask> explained below. It basically tells Flask to think we are handling a <mask> request even though we are not, we are in an interactive Python shell. <mask> Have a look at the explanation below. :ref:`context-locals`). <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
are handled as the `HTTP RFC`_ (the document describing the HTTP
<mask> show_the_login_form() <mask> <mask> If `GET` is present, `HEAD` will be added automatically for you. You <mask> don't have to deal with that. It will also make sure that `HEAD` requests <mask> are handled like the `HTTP RFC`_ (the document describing the HTTP <mask> protocol) demands, so you...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
specification. Likewise, as of Flask 0.6, `OPTIONS` is implemented for you automatically as well.
<mask> If `GET` is present, `HEAD` will be added automatically for you. You <mask> don't have to deal with that. It will also make sure that `HEAD` requests <mask> are handled like the `HTTP RFC`_ (the document describing the HTTP <mask> protocol) demands, so you can completely ignore that part of the HTTP <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
stored and only stored once. This is how HTML forms usually transmit data to the server.
<mask> <mask> `POST` <mask> The browser tells the server that it wants to *post* some new <mask> information to that URL and that the server must ensure the data is <mask> stored and only stored once. This is how HTML forms are usually <mask> transmitting data to the server. <mask> <mask> `PU...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
might be asking why this is useful, but there are some good reasons to do it this way. Consider that the connection is lost during
<mask> <mask> `PUT` <mask> Similar to `POST` but the server might trigger the store procedure <mask> multiple times by overwriting the old values more than once. Now you <mask> might be asking why is this useful, but there are some good reasons <mask> to do it this way. Consider that the connec...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
Dynamic web applications also need static files. That's usually where
<mask> <mask> Static Files <mask> ------------ <mask> <mask> Dynamic web applications need static files as well. That's usually where <mask> the CSS and JavaScript files are coming from. Ideally your web server is <mask> configured to serve them for you, but during development Flask can do that <mask> as we...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
To generate URLs that part of the URL, use the special ``'static'`` URL
<mask> configured to serve them for you, but during development Flask can do that <mask> as well. Just create a folder called `static` in your package or next to <mask> your module and it will be available at `/static` on the application. <mask> <mask> To generate URLs to that part of the URL, use the special ``...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
method. All you have to do is provide the name of the template and the
<mask> the application secure. Because of that Flask configures the `Jinja2 <mask> <http://jinja.pocoo.org/2/>`_ template engine for you automatically. <mask> <mask> To render a template you can use the :func:`~flask.render_template` <mask> method. All you have to do is to provide the name of the template and t...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
application is a module, this folder is next to that module, if it's a
<mask> def hello(name=None): <mask> return render_template('hello.html', name=name) <mask> <mask> Flask will look for templates in the `templates` folder. So if your <mask> application is a module, that folder is next to that module, if it's a <mask> package it's actually inside your package: <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
Automatic escaping is enabled, so if `name` contains HTML it will be escaped
<mask> know how that works, head over to the :ref:`template-inheritance` pattern <mask> documentation. Basically template inheritance makes it possible to keep <mask> certain elements on each page (like header, navigation and footer). <mask> <mask> Automatic escaping is enabled, so if name contains HTML it will ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
safe HTML (for example because it came from a module that converts wiki
<mask> certain elements on each page (like header, navigation and footer). <mask> <mask> Automatic escaping is enabled, so if name contains HTML it will be escaped <mask> automatically. If you can trust a variable and you know that it will be <mask> safe HTML (because for example it came from a module that conve...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
manages to still be threadsafe. The answer is context locals:
<mask> For web applications it's crucial to react to the data a client sent to <mask> the server. In Flask this information is provided by the global <mask> :class:`~flask.request` object. If you have some experience with Python <mask> you might be wondering how that object can be global and how Flask <mask> man...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
web server decides to spawn a new thread (or something else, the underlying object is capable of dealing with concurrency systems other than threads). When Flask starts its internal request handling it
<mask> These objects are actually proxies to objects that are local to a specific <mask> context. What a mouthful. But that is actually quite easy to understand. <mask> <mask> Imagine the context being the handling thread. A request comes in and the <mask> webserver decides to spawn a new thread (or something ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
It does that in an intelligent way so that one application can invoke another
<mask> underlying object is capable of dealing with other concurrency systems <mask> than threads as well). When Flask starts its internal request handling it <mask> figures out that the current thread is the active context and binds the <mask> current application and the WSGI environments to that context (thread)...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
this is the case unless you are doing something like unit testing. You will notice that code which depends on a request object will suddenly break
<mask> It does that in an intelligent way that one application can invoke another <mask> application without breaking. <mask> <mask> So what does this mean to you? Basically you can completely ignore that <mask> this is the case unless you are doing something like unittesting. You <mask> will notice that code ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
unit testing is to use the :meth:`~flask.Flask.test_request_context`
<mask> this is the case unless you are doing something like unittesting. You <mask> will notice that code that depends on a request object will suddenly break <mask> because there is no request object. The solution is creating a request <mask> object yourself and binding it to the context. The easiest solution f...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
4. If none of that works, Flask will assume the return value is a valid WSGI application and convert that into a response object.
<mask> 2. If it's a string, a response object is created with that data and the <mask> default parameters. <mask> 3. If a tuple is returned the response object is created by passing the <mask> tuple as arguments to the response object's constructor. <mask> 4. If neither of that works, Flask will assume ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
In addition to the request object there is also a second object called :class:`~flask.session` which allows you to store information specific to a
<mask> <mask> Sessions <mask> -------- <mask> <mask> Besides the request object there is also a second object called <mask> :class:`~flask.session` that allows you to store information specific to a <mask> user from one request to the next. This is implemented on top of cookies <mask> for you and signs the c...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
The :func:`~flask.escape` mentioned here does escaping for you if you are not using the template engine (as in this example).
<mask> <mask> # set the secret key. keep this really secret: <mask> app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT' <mask> <mask> The here mentioned :func:`~flask.escape` does escaping for you if you are <mask> not using the template engine (like in this example). <mask> <mask> .. admonition:: How...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
The problem with random is that it's hard to judge what is truly random. And
<mask> not using the template engine (like in this example). <mask> <mask> .. admonition:: How to generate good secret keys <mask> <mask> The problem with random is that it's hard to judge what random is. And <mask> a secret key should be as random as possible. Your operating system <mask> has ways ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst
possible to record a message at the end of a request and access it on the next (and only the next) request. This is usually combined with a layout template to expose the message.
<mask> Good applications and user interfaces are all about feedback. If the user <mask> does not get enough feedback they will probably end up hating the <mask> application. Flask provides a really simple way to give feedback to a <mask> user with the flashing system. The flashing system basically makes it <mas...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7ccca13bbdfcbab126722c050dc4ea3d8fa56dc3
docs/quickstart.rst