Skip to content
Myr

add app.query route decorator

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 3596b1a · Browse files · 3 files+14 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+14 added−2 removed

  • tests:+5 added−2 removed
  • other:+9 added−0 removed

3 files+14 added−2 removed

modified:src/flask/sansio/scaffold.py+8 added
299 unmodified lines
300 """301 return self._method_route("GET", rule, options)302303 @setupmethod304 def query(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]:305 """Shortcut for :meth:`route` with ``methods=["QUERY"]``.306307 .. versionadded:: 3.2308 """309 return self._method_route("QUERY", rule, options)310311 @setupmethod312 def post(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]:313 """Shortcut for :meth:`route` with ``methods=["POST"]``.314315 .. versionadded:: 2.0
485 unmodified lines
modified:tests/test_basic.py+5 added-2 removed
5 unmodified lines
6import weakref7from contextlib import nullcontext8from datetime import datetime9from datetime import timezone10from functools import partial11from platform import python_implementation1213import pytest14import werkzeug.serving
37 unmodified lines
52 rv = client.open("/", method="OPTIONS")53 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]545555@pytest.mark.parametrize("method", ["get", "post", "put", "delete", "patch"])56@pytest.mark.parametrize("method", ["get", "query", "post", "put", "delete", "patch"])57def test_method_route(app, client, method):58 method_route = getattr(app, method)58 client_method = getattr(client, method)59 client_method = getattr(60 client, method, partial(client.open, method=method.capitalize())61 )6263 @method_route("/")64 def hello():65 return "Hello"
1909 unmodified lines
modified:CHANGES.rst+1 added
27 unmodified lines
28 it's disabled in config. Previously, only disabling worked. :issue:`5916`29- ``Flask.select_jinja_autoescape`` uses case-insensitive comparison instead30 of only lower case file extensions. :pr:`6012`31- Fix parsing IPv6 with port in ``run`` and the test client. :pr:`6096`32- Add ``app.query`` route decorator for the HTTP QUERY method.333435Version 3.1.336-------------
1631 unmodified lines