`RequestContext.match_request` is moved from `__init__` to `push`. This
causes matching to happen later, when the app context is available.
This enables URL converters that use things such as the database.
After pallets/werkzeug#1577, mismatched configured and real server
names will show a warning in addition to raising 404. This caused
tests that did this deliberately to fail.
This patch removes the pytest fixture we were using to fail on
warnings, instead using the standard `-Werror` option. This speeds
up the tests by ~3x.
Before, returning a `bool` from a route caused the error
```
[2019-05-31 10:08:42,216] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2070, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 269, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 26, in _run_wsgi_app
return _run_wsgi_app(*args)
File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/test.py", line 1119, in run_wsgi_app
app_rv = app(environ, start_response)
TypeError: 'bool' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2393, in wsgi_app
response = self.full_dispatch_request()
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1906, in full_dispatch_request
return self.finalize_request(rv)
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1921, in finalize_request
response = self.make_response(rv)
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2078, in make_response
reraise(TypeError, new_error, sys.exc_info()[2])
File "/Users/johnzeringue/Documents/ts-open/flask/flask/_compat.py", line 39, in reraise
raise value.with_traceback(tb)
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2070, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 269, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 26, in _run_wsgi_app
return _run_wsgi_app(*args)
File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/test.py", line 1119, in run_wsgi_app
app_rv = app(environ, start_response)
TypeError: 'bool' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a bool.
```
Now, it returns the more readable
```
[2019-05-31 10:36:19,500] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2400, in wsgi_app
response = self.full_dispatch_request()
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1907, in full_dispatch_request
return self.finalize_request(rv)
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1922, in finalize_request
response = self.make_response(rv)
File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2085, in make_response
" {rv.__class__.__name__}.".format(rv=rv))
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a bool.
```
Fixes#3214
-prefix a path delimiter iff there's a path to delimit
-ensures a valid default static route rule is created on application
intialisation for the case 'static_folder=""' and implicit
'static_url_path'
This supports an increasingly common usecase whereby JSON is the
primary response (rather than a templated string). Given Flask has a
short syntax for HTML reponses, it seems fitting that it should also
do so for JSON responses. In practice it allows,
@app.route("/")
def index():
return {
"api_stuff": "values",
}
rename new subdomain test, parametrize
test allowing subdomains as well as ips
add subdomain_matching param to docs
add some references to docs
add version changed to create_url_adapter
* add fixtures to conftest.py
* use fixtures in test_appctx.py
* use fixtures in test_blueprints.py
* use fixtures in test_depreciations.py
* use fixtures in test_regressions.py
* use fixtures in test_reqctx.py
* use fixtures in test_templating.py
* use fixtures in test_user_error_handler.py
* use fixtures in test_views.py
* use fixtures in test_basics.py
* use fixtures in test_helpers.py
* use fixtures in test_testing.py
* update conftest.py
* make docstrings PEP-257 compliant
* cleanup
* switch dictonary format
* use pytest parameterization for test_json_as_unicode
* be explicit about how tuples are unpacked
* allow bytes for status value
* allow Headers for headers value
* use TypeError instead of ValueError
* errors are more descriptive
* document that view must not return None
* update documentation about return values
* test more response types
* test error messages
closes#1676
This enables host_matching to be set properly by the time the constructor adds
the static route, and enables the static route to be properly associated with
the required host.
Previously, you could only enable host_matching once your app was already
instantiated (e.g. app.url_map.host_matching = True), but at that point
the constructor would have already added the static route without host matching
and an associated host, leaving the static route in a broken state.
Fixes#1559.
* Don't rely on X-Requested-With for pretty print json response
* Fix test cases for pretty print json patch
* Fix gramma error in docs for pretty print json config
* Add changelog for JSONIFY_PRETTYPRINT_REGULAR
Adds support for a kwarg `provide_automatic_options` on `add_url_rule`, which
lets you turn off the automatic OPTIONS response on a per-URL basis even if
your view functions are functions, not classes (so you can't provide attrs
on them).
Looks like that was meant to be `config_key`. It works by accident because the function is defined in the same scope as the look that passes `config_key` to `apprunner`.