id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
231,700 | pgjones/quart | quart/blueprints.py | Blueprint.after_request | def after_request(self, func: Callable) -> Callable:
"""Add an after request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies only to requests that
are routed to an endpoint in this bluepr... | python | def after_request(self, func: Callable) -> Callable:
"""Add an after request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies only to requests that
are routed to an endpoint in this bluepr... | [
"def",
"after_request",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"after_request",
"(",
"func",
",",
"self",
".",
"name",
")",
")",
"return"... | Add an after request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies only to requests that
are routed to an endpoint in this blueprint. An example usage,
.. code-block:: python
... | [
"Add",
"an",
"after",
"request",
"function",
"to",
"the",
"Blueprint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L396-L411 |
231,701 | pgjones/quart | quart/blueprints.py | Blueprint.after_websocket | def after_websocket(self, func: Callable) -> Callable:
"""Add an after websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies only to requests that
are routed to an endpoint in this ... | python | def after_websocket(self, func: Callable) -> Callable:
"""Add an after websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies only to requests that
are routed to an endpoint in this ... | [
"def",
"after_websocket",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"after_websocket",
"(",
"func",
",",
"self",
".",
"name",
")",
")",
"ret... | Add an after websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies only to requests that
are routed to an endpoint in this blueprint. An example usage,
.. code-block:: python
... | [
"Add",
"an",
"after",
"websocket",
"function",
"to",
"the",
"Blueprint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L413-L428 |
231,702 | pgjones/quart | quart/blueprints.py | Blueprint.after_app_request | def after_app_request(self, func: Callable) -> Callable:
"""Add a after request function to the app.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies to all requests to the
app this blueprint is registered on. An ex... | python | def after_app_request(self, func: Callable) -> Callable:
"""Add a after request function to the app.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies to all requests to the
app this blueprint is registered on. An ex... | [
"def",
"after_app_request",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"after_request",
"(",
"func",
")",
")",
"return",
"func"
] | Add a after request function to the app.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies to all requests to the
app this blueprint is registered on. An example usage,
.. code-block:: python
blueprint ... | [
"Add",
"a",
"after",
"request",
"function",
"to",
"the",
"app",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L430-L445 |
231,703 | pgjones/quart | quart/blueprints.py | Blueprint.after_app_websocket | def after_app_websocket(self, func: Callable) -> Callable:
"""Add an after websocket function to the App.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies to all requests to the
ppe this blueprint is registerd on.... | python | def after_app_websocket(self, func: Callable) -> Callable:
"""Add an after websocket function to the App.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies to all requests to the
ppe this blueprint is registerd on.... | [
"def",
"after_app_websocket",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"after_websocket",
"(",
"func",
")",
")",
"return",
"func"
] | Add an after websocket function to the App.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies to all requests to the
ppe this blueprint is registerd on. An example usage,
.. code-block:: python
bluepr... | [
"Add",
"an",
"after",
"websocket",
"function",
"to",
"the",
"App",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L447-L462 |
231,704 | pgjones/quart | quart/blueprints.py | Blueprint.teardown_request | def teardown_request(self, func: Callable) -> Callable:
"""Add a teardown request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.teardown_request`. It applies only to requests that
are routed to an endpoint in thi... | python | def teardown_request(self, func: Callable) -> Callable:
"""Add a teardown request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.teardown_request`. It applies only to requests that
are routed to an endpoint in thi... | [
"def",
"teardown_request",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"teardown_request",
"(",
"func",
",",
"self",
".",
"name",
")",
")",
"r... | Add a teardown request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.teardown_request`. It applies only to requests that
are routed to an endpoint in this blueprint. An example usage,
.. code-block:: python
... | [
"Add",
"a",
"teardown",
"request",
"function",
"to",
"the",
"Blueprint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L464-L479 |
231,705 | pgjones/quart | quart/blueprints.py | Blueprint.teardown_websocket | def teardown_websocket(self, func: Callable) -> Callable:
"""Add a teardown websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_websocket`. It
applies only to requests that are routed to an endpoint ... | python | def teardown_websocket(self, func: Callable) -> Callable:
"""Add a teardown websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_websocket`. It
applies only to requests that are routed to an endpoint ... | [
"def",
"teardown_websocket",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"teardown_websocket",
"(",
"func",
",",
"self",
".",
"name",
")",
")",
... | Add a teardown websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_websocket`. It
applies only to requests that are routed to an endpoint in
this blueprint. An example usage,
.. code-block::... | [
"Add",
"a",
"teardown",
"websocket",
"function",
"to",
"the",
"Blueprint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L481-L498 |
231,706 | pgjones/quart | quart/blueprints.py | Blueprint.teardown_app_request | def teardown_app_request(self, func: Callable) -> Callable:
"""Add a teardown request function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_request`. It applies
to all requests to the app this blueprint is registered ... | python | def teardown_app_request(self, func: Callable) -> Callable:
"""Add a teardown request function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_request`. It applies
to all requests to the app this blueprint is registered ... | [
"def",
"teardown_app_request",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"teardown_request",
"(",
"func",
")",
")",
"return",
"func"
] | Add a teardown request function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_request`. It applies
to all requests to the app this blueprint is registered on. An
example usage,
.. code-block:: python
... | [
"Add",
"a",
"teardown",
"request",
"function",
"to",
"the",
"app",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L500-L516 |
231,707 | pgjones/quart | quart/blueprints.py | Blueprint.errorhandler | def errorhandler(self, error: Union[Type[Exception], int]) -> Callable:
"""Add an error handler function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to errors that originate in routes in t... | python | def errorhandler(self, error: Union[Type[Exception], int]) -> Callable:
"""Add an error handler function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to errors that originate in routes in t... | [
"def",
"errorhandler",
"(",
"self",
",",
"error",
":",
"Union",
"[",
"Type",
"[",
"Exception",
"]",
",",
"int",
"]",
")",
"->",
"Callable",
":",
"def",
"decorator",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"register_error_... | Add an error handler function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to errors that originate in routes in this blueprint. An
example usage,
.. code-block:: python
... | [
"Add",
"an",
"error",
"handler",
"function",
"to",
"the",
"Blueprint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L518-L537 |
231,708 | pgjones/quart | quart/blueprints.py | Blueprint.app_errorhandler | def app_errorhandler(self, error: Union[Type[Exception], int]) -> Callable:
"""Add an error handler function to the App.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to all errors. An example usage,
... | python | def app_errorhandler(self, error: Union[Type[Exception], int]) -> Callable:
"""Add an error handler function to the App.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to all errors. An example usage,
... | [
"def",
"app_errorhandler",
"(",
"self",
",",
"error",
":",
"Union",
"[",
"Type",
"[",
"Exception",
"]",
",",
"int",
"]",
")",
"->",
"Callable",
":",
"def",
"decorator",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once... | Add an error handler function to the App.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to all errors. An example usage,
.. code-block:: python
blueprint = Blueprint(__name__)
@bluep... | [
"Add",
"an",
"error",
"handler",
"function",
"to",
"the",
"App",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L539-L556 |
231,709 | pgjones/quart | quart/blueprints.py | Blueprint.register_error_handler | def register_error_handler(self, error: Union[Type[Exception], int], func: Callable) -> None:
"""Add an error handler function to the blueprint.
This is designed to be used on the blueprint directly, and
has the same arguments as
:meth:`~quart.Quart.register_error_handler`. An example u... | python | def register_error_handler(self, error: Union[Type[Exception], int], func: Callable) -> None:
"""Add an error handler function to the blueprint.
This is designed to be used on the blueprint directly, and
has the same arguments as
:meth:`~quart.Quart.register_error_handler`. An example u... | [
"def",
"register_error_handler",
"(",
"self",
",",
"error",
":",
"Union",
"[",
"Type",
"[",
"Exception",
"]",
",",
"int",
"]",
",",
"func",
":",
"Callable",
")",
"->",
"None",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
... | Add an error handler function to the blueprint.
This is designed to be used on the blueprint directly, and
has the same arguments as
:meth:`~quart.Quart.register_error_handler`. An example usage,
.. code-block:: python
def not_found():
...
blue... | [
"Add",
"an",
"error",
"handler",
"function",
"to",
"the",
"blueprint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L558-L573 |
231,710 | pgjones/quart | quart/blueprints.py | Blueprint.context_processor | def context_processor(self, func: Callable) -> Callable:
"""Add a context processor function to this blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered in this bluep... | python | def context_processor(self, func: Callable) -> Callable:
"""Add a context processor function to this blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered in this bluep... | [
"def",
"context_processor",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"context_processor",
"(",
"func",
",",
"self",
".",
"name",
")",
")",
... | Add a context processor function to this blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered in this blueprint's
routes. An example usage,
.. code-block:: py... | [
"Add",
"a",
"context",
"processor",
"function",
"to",
"this",
"blueprint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L575-L591 |
231,711 | pgjones/quart | quart/blueprints.py | Blueprint.app_context_processor | def app_context_processor(self, func: Callable) -> Callable:
"""Add a context processor function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered. An example usag... | python | def app_context_processor(self, func: Callable) -> Callable:
"""Add a context processor function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered. An example usag... | [
"def",
"app_context_processor",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"context_processor",
"(",
"func",
")",
")",
"return",
"func"
] | Add a context processor function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered. An example usage,
.. code-block:: python
blueprint = Blueprint(__... | [
"Add",
"a",
"context",
"processor",
"function",
"to",
"the",
"app",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L593-L608 |
231,712 | pgjones/quart | quart/blueprints.py | Blueprint.record_once | def record_once(self, func: DeferedSetupFunction) -> None:
"""Used to register a deferred action that happens only once."""
def wrapper(state: 'BlueprintSetupState') -> None:
if state.first_registration:
func(state)
self.record(update_wrapper(wrapper, func)) | python | def record_once(self, func: DeferedSetupFunction) -> None:
"""Used to register a deferred action that happens only once."""
def wrapper(state: 'BlueprintSetupState') -> None:
if state.first_registration:
func(state)
self.record(update_wrapper(wrapper, func)) | [
"def",
"record_once",
"(",
"self",
",",
"func",
":",
"DeferedSetupFunction",
")",
"->",
"None",
":",
"def",
"wrapper",
"(",
"state",
":",
"'BlueprintSetupState'",
")",
"->",
"None",
":",
"if",
"state",
".",
"first_registration",
":",
"func",
"(",
"state",
... | Used to register a deferred action that happens only once. | [
"Used",
"to",
"register",
"a",
"deferred",
"action",
"that",
"happens",
"only",
"once",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L687-L692 |
231,713 | pgjones/quart | quart/blueprints.py | Blueprint.register | def register(
self,
app: 'Quart',
first_registration: bool,
*,
url_prefix: Optional[str]=None,
) -> None:
"""Register this blueprint on the app given."""
state = self.make_setup_state(app, first_registration, url_prefix=url_prefix)
... | python | def register(
self,
app: 'Quart',
first_registration: bool,
*,
url_prefix: Optional[str]=None,
) -> None:
"""Register this blueprint on the app given."""
state = self.make_setup_state(app, first_registration, url_prefix=url_prefix)
... | [
"def",
"register",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"first_registration",
":",
"bool",
",",
"*",
",",
"url_prefix",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"state",
"=",
"self",
".",
"make_setup_state",
... | Register this blueprint on the app given. | [
"Register",
"this",
"blueprint",
"on",
"the",
"app",
"given",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L694-L711 |
231,714 | pgjones/quart | quart/blueprints.py | Blueprint.make_setup_state | def make_setup_state(
self,
app: 'Quart',
first_registration: bool,
*,
url_prefix: Optional[str]=None,
) -> 'BlueprintSetupState':
"""Return a blueprint setup state instance.
Arguments:
first_registration: True if this is the f... | python | def make_setup_state(
self,
app: 'Quart',
first_registration: bool,
*,
url_prefix: Optional[str]=None,
) -> 'BlueprintSetupState':
"""Return a blueprint setup state instance.
Arguments:
first_registration: True if this is the f... | [
"def",
"make_setup_state",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"first_registration",
":",
"bool",
",",
"*",
",",
"url_prefix",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"'BlueprintSetupState'",
":",
"return",
"BlueprintSetupSta... | Return a blueprint setup state instance.
Arguments:
first_registration: True if this is the first registration
of this blueprint on the app.
url_prefix: An optional prefix to all rules | [
"Return",
"a",
"blueprint",
"setup",
"state",
"instance",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L713-L727 |
231,715 | pgjones/quart | quart/datastructures.py | _WerkzeugMultidictMixin.to_dict | def to_dict(self, flat: bool=True) -> Dict[Any, Any]:
"""Convert the multidict to a plain dictionary.
Arguments:
flat: If True only return the a value for each key, if
False return all values as lists.
"""
if flat:
return {key: value for key, val... | python | def to_dict(self, flat: bool=True) -> Dict[Any, Any]:
"""Convert the multidict to a plain dictionary.
Arguments:
flat: If True only return the a value for each key, if
False return all values as lists.
"""
if flat:
return {key: value for key, val... | [
"def",
"to_dict",
"(",
"self",
",",
"flat",
":",
"bool",
"=",
"True",
")",
"->",
"Dict",
"[",
"Any",
",",
"Any",
"]",
":",
"if",
"flat",
":",
"return",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"self",
".",
"items",
"(",
")",
... | Convert the multidict to a plain dictionary.
Arguments:
flat: If True only return the a value for each key, if
False return all values as lists. | [
"Convert",
"the",
"multidict",
"to",
"a",
"plain",
"dictionary",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/datastructures.py#L42-L53 |
231,716 | pgjones/quart | quart/datastructures.py | FileStorage.save | def save(self, destination: BinaryIO, buffer_size: int=16384) -> None:
"""Save the file to the destination.
Arguments:
destination: A filename (str) or file object to write to.
buffer_size: Buffer size as used as length in
:func:`shutil.copyfileobj`.
"""
... | python | def save(self, destination: BinaryIO, buffer_size: int=16384) -> None:
"""Save the file to the destination.
Arguments:
destination: A filename (str) or file object to write to.
buffer_size: Buffer size as used as length in
:func:`shutil.copyfileobj`.
"""
... | [
"def",
"save",
"(",
"self",
",",
"destination",
":",
"BinaryIO",
",",
"buffer_size",
":",
"int",
"=",
"16384",
")",
"->",
"None",
":",
"close_destination",
"=",
"False",
"if",
"isinstance",
"(",
"destination",
",",
"str",
")",
":",
"destination",
"=",
"o... | Save the file to the destination.
Arguments:
destination: A filename (str) or file object to write to.
buffer_size: Buffer size as used as length in
:func:`shutil.copyfileobj`. | [
"Save",
"the",
"file",
"to",
"the",
"destination",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/datastructures.py#L136-L152 |
231,717 | pgjones/quart | quart/wrappers/request.py | Request.get_data | async def get_data(self, raw: bool=True) -> AnyStr:
"""The request body data."""
try:
body_future = asyncio.ensure_future(self.body)
raw_data = await asyncio.wait_for(body_future, timeout=self.body_timeout)
except asyncio.TimeoutError:
body_future.cancel()
... | python | async def get_data(self, raw: bool=True) -> AnyStr:
"""The request body data."""
try:
body_future = asyncio.ensure_future(self.body)
raw_data = await asyncio.wait_for(body_future, timeout=self.body_timeout)
except asyncio.TimeoutError:
body_future.cancel()
... | [
"async",
"def",
"get_data",
"(",
"self",
",",
"raw",
":",
"bool",
"=",
"True",
")",
"->",
"AnyStr",
":",
"try",
":",
"body_future",
"=",
"asyncio",
".",
"ensure_future",
"(",
"self",
".",
"body",
")",
"raw_data",
"=",
"await",
"asyncio",
".",
"wait_for... | The request body data. | [
"The",
"request",
"body",
"data",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/request.py#L158-L171 |
231,718 | pgjones/quart | quart/wrappers/request.py | Websocket.accept | async def accept(
self,
headers: Optional[Union[dict, CIMultiDict, Headers]] = None,
subprotocol: Optional[str] = None,
) -> None:
"""Manually chose to accept the websocket connection.
Arguments:
headers: Additional headers to send with the acceptance... | python | async def accept(
self,
headers: Optional[Union[dict, CIMultiDict, Headers]] = None,
subprotocol: Optional[str] = None,
) -> None:
"""Manually chose to accept the websocket connection.
Arguments:
headers: Additional headers to send with the acceptance... | [
"async",
"def",
"accept",
"(",
"self",
",",
"headers",
":",
"Optional",
"[",
"Union",
"[",
"dict",
",",
"CIMultiDict",
",",
"Headers",
"]",
"]",
"=",
"None",
",",
"subprotocol",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"None",
... | Manually chose to accept the websocket connection.
Arguments:
headers: Additional headers to send with the acceptance
response.
subprotocol: The chosen subprotocol, optional. | [
"Manually",
"chose",
"to",
"accept",
"the",
"websocket",
"connection",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/request.py#L326-L342 |
231,719 | pgjones/quart | quart/logging.py | create_logger | def create_logger(app: 'Quart') -> Logger:
"""Create a logger for the app based on the app settings.
This creates a logger named quart.app that has a log level based
on the app configuration.
"""
logger = getLogger('quart.app')
if app.debug and logger.level == NOTSET:
logger.setLevel(D... | python | def create_logger(app: 'Quart') -> Logger:
"""Create a logger for the app based on the app settings.
This creates a logger named quart.app that has a log level based
on the app configuration.
"""
logger = getLogger('quart.app')
if app.debug and logger.level == NOTSET:
logger.setLevel(D... | [
"def",
"create_logger",
"(",
"app",
":",
"'Quart'",
")",
"->",
"Logger",
":",
"logger",
"=",
"getLogger",
"(",
"'quart.app'",
")",
"if",
"app",
".",
"debug",
"and",
"logger",
".",
"level",
"==",
"NOTSET",
":",
"logger",
".",
"setLevel",
"(",
"DEBUG",
"... | Create a logger for the app based on the app settings.
This creates a logger named quart.app that has a log level based
on the app configuration. | [
"Create",
"a",
"logger",
"for",
"the",
"app",
"based",
"on",
"the",
"app",
"settings",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/logging.py#L15-L27 |
231,720 | pgjones/quart | quart/logging.py | create_serving_logger | def create_serving_logger() -> Logger:
"""Create a logger for serving.
This creates a logger named quart.serving.
"""
logger = getLogger('quart.serving')
if logger.level == NOTSET:
logger.setLevel(INFO)
logger.addHandler(serving_handler)
return logger | python | def create_serving_logger() -> Logger:
"""Create a logger for serving.
This creates a logger named quart.serving.
"""
logger = getLogger('quart.serving')
if logger.level == NOTSET:
logger.setLevel(INFO)
logger.addHandler(serving_handler)
return logger | [
"def",
"create_serving_logger",
"(",
")",
"->",
"Logger",
":",
"logger",
"=",
"getLogger",
"(",
"'quart.serving'",
")",
"if",
"logger",
".",
"level",
"==",
"NOTSET",
":",
"logger",
".",
"setLevel",
"(",
"INFO",
")",
"logger",
".",
"addHandler",
"(",
"servi... | Create a logger for serving.
This creates a logger named quart.serving. | [
"Create",
"a",
"logger",
"for",
"serving",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/logging.py#L30-L41 |
231,721 | pgjones/quart | quart/utils.py | create_cookie | def create_cookie(
key: str,
value: str='',
max_age: Optional[Union[int, timedelta]]=None,
expires: Optional[Union[int, float, datetime]]=None,
path: str='/',
domain: Optional[str]=None,
secure: bool=False,
httponly: bool=False,
) -> SimpleCookie:
"""C... | python | def create_cookie(
key: str,
value: str='',
max_age: Optional[Union[int, timedelta]]=None,
expires: Optional[Union[int, float, datetime]]=None,
path: str='/',
domain: Optional[str]=None,
secure: bool=False,
httponly: bool=False,
) -> SimpleCookie:
"""C... | [
"def",
"create_cookie",
"(",
"key",
":",
"str",
",",
"value",
":",
"str",
"=",
"''",
",",
"max_age",
":",
"Optional",
"[",
"Union",
"[",
"int",
",",
"timedelta",
"]",
"]",
"=",
"None",
",",
"expires",
":",
"Optional",
"[",
"Union",
"[",
"int",
",",... | Create a Cookie given the options set
The arguments are the standard cookie morsels and this is a
wrapper around the stdlib SimpleCookie code. | [
"Create",
"a",
"Cookie",
"given",
"the",
"options",
"set"
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/utils.py#L29-L59 |
231,722 | pgjones/quart | quart/app.py | Quart.name | def name(self) -> str:
"""The name of this application.
This is taken from the :attr:`import_name` and is used for
debugging purposes.
"""
if self.import_name == '__main__':
path = Path(getattr(sys.modules['__main__'], '__file__', '__main__.py'))
return p... | python | def name(self) -> str:
"""The name of this application.
This is taken from the :attr:`import_name` and is used for
debugging purposes.
"""
if self.import_name == '__main__':
path = Path(getattr(sys.modules['__main__'], '__file__', '__main__.py'))
return p... | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"import_name",
"==",
"'__main__'",
":",
"path",
"=",
"Path",
"(",
"getattr",
"(",
"sys",
".",
"modules",
"[",
"'__main__'",
"]",
",",
"'__file__'",
",",
"'__main__.py'",
")",
")",
... | The name of this application.
This is taken from the :attr:`import_name` and is used for
debugging purposes. | [
"The",
"name",
"of",
"this",
"application",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L223-L232 |
231,723 | pgjones/quart | quart/app.py | Quart.jinja_env | def jinja_env(self) -> Environment:
"""The jinja environment used to load templates."""
if self._jinja_env is None:
self._jinja_env = self.create_jinja_environment()
return self._jinja_env | python | def jinja_env(self) -> Environment:
"""The jinja environment used to load templates."""
if self._jinja_env is None:
self._jinja_env = self.create_jinja_environment()
return self._jinja_env | [
"def",
"jinja_env",
"(",
"self",
")",
"->",
"Environment",
":",
"if",
"self",
".",
"_jinja_env",
"is",
"None",
":",
"self",
".",
"_jinja_env",
"=",
"self",
".",
"create_jinja_environment",
"(",
")",
"return",
"self",
".",
"_jinja_env"
] | The jinja environment used to load templates. | [
"The",
"jinja",
"environment",
"used",
"to",
"load",
"templates",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L261-L265 |
231,724 | pgjones/quart | quart/app.py | Quart.auto_find_instance_path | def auto_find_instance_path(self) -> Path:
"""Locates the instace_path if it was not provided
"""
prefix, package_path = find_package(self.import_name)
if prefix is None:
return package_path / "instance"
return prefix / "var" / f"{self.name}-instance" | python | def auto_find_instance_path(self) -> Path:
"""Locates the instace_path if it was not provided
"""
prefix, package_path = find_package(self.import_name)
if prefix is None:
return package_path / "instance"
return prefix / "var" / f"{self.name}-instance" | [
"def",
"auto_find_instance_path",
"(",
"self",
")",
"->",
"Path",
":",
"prefix",
",",
"package_path",
"=",
"find_package",
"(",
"self",
".",
"import_name",
")",
"if",
"prefix",
"is",
"None",
":",
"return",
"package_path",
"/",
"\"instance\"",
"return",
"prefix... | Locates the instace_path if it was not provided | [
"Locates",
"the",
"instace_path",
"if",
"it",
"was",
"not",
"provided"
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L272-L278 |
231,725 | pgjones/quart | quart/app.py | Quart.make_config | def make_config(self, instance_relative: bool = False) -> Config:
"""Create and return the configuration with appropriate defaults."""
config = self.config_class(
self.instance_path if instance_relative else self.root_path,
DEFAULT_CONFIG,
)
config['ENV'] = get_en... | python | def make_config(self, instance_relative: bool = False) -> Config:
"""Create and return the configuration with appropriate defaults."""
config = self.config_class(
self.instance_path if instance_relative else self.root_path,
DEFAULT_CONFIG,
)
config['ENV'] = get_en... | [
"def",
"make_config",
"(",
"self",
",",
"instance_relative",
":",
"bool",
"=",
"False",
")",
"->",
"Config",
":",
"config",
"=",
"self",
".",
"config_class",
"(",
"self",
".",
"instance_path",
"if",
"instance_relative",
"else",
"self",
".",
"root_path",
",",... | Create and return the configuration with appropriate defaults. | [
"Create",
"and",
"return",
"the",
"configuration",
"with",
"appropriate",
"defaults",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L280-L288 |
231,726 | pgjones/quart | quart/app.py | Quart.create_url_adapter | def create_url_adapter(self, request: Optional[BaseRequestWebsocket]) -> Optional[MapAdapter]:
"""Create and return a URL adapter.
This will create the adapter based on the request if present
otherwise the app configuration.
"""
if request is not None:
host = request... | python | def create_url_adapter(self, request: Optional[BaseRequestWebsocket]) -> Optional[MapAdapter]:
"""Create and return a URL adapter.
This will create the adapter based on the request if present
otherwise the app configuration.
"""
if request is not None:
host = request... | [
"def",
"create_url_adapter",
"(",
"self",
",",
"request",
":",
"Optional",
"[",
"BaseRequestWebsocket",
"]",
")",
"->",
"Optional",
"[",
"MapAdapter",
"]",
":",
"if",
"request",
"is",
"not",
"None",
":",
"host",
"=",
"request",
".",
"host",
"return",
"self... | Create and return a URL adapter.
This will create the adapter based on the request if present
otherwise the app configuration. | [
"Create",
"and",
"return",
"a",
"URL",
"adapter",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L302-L318 |
231,727 | pgjones/quart | quart/app.py | Quart.create_jinja_environment | def create_jinja_environment(self) -> Environment:
"""Create and return the jinja environment.
This will create the environment based on the
:attr:`jinja_options` and configuration settings. The
environment will include the Quart globals by default.
"""
options = dict(se... | python | def create_jinja_environment(self) -> Environment:
"""Create and return the jinja environment.
This will create the environment based on the
:attr:`jinja_options` and configuration settings. The
environment will include the Quart globals by default.
"""
options = dict(se... | [
"def",
"create_jinja_environment",
"(",
"self",
")",
"->",
"Environment",
":",
"options",
"=",
"dict",
"(",
"self",
".",
"jinja_options",
")",
"if",
"'autoescape'",
"not",
"in",
"options",
":",
"options",
"[",
"'autoescape'",
"]",
"=",
"self",
".",
"select_j... | Create and return the jinja environment.
This will create the environment based on the
:attr:`jinja_options` and configuration settings. The
environment will include the Quart globals by default. | [
"Create",
"and",
"return",
"the",
"jinja",
"environment",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L320-L342 |
231,728 | pgjones/quart | quart/app.py | Quart.select_jinja_autoescape | def select_jinja_autoescape(self, filename: str) -> bool:
"""Returns True if the filename indicates that it should be escaped."""
if filename is None:
return True
return Path(filename).suffix in {'.htm', '.html', '.xhtml', '.xml'} | python | def select_jinja_autoescape(self, filename: str) -> bool:
"""Returns True if the filename indicates that it should be escaped."""
if filename is None:
return True
return Path(filename).suffix in {'.htm', '.html', '.xhtml', '.xml'} | [
"def",
"select_jinja_autoescape",
"(",
"self",
",",
"filename",
":",
"str",
")",
"->",
"bool",
":",
"if",
"filename",
"is",
"None",
":",
"return",
"True",
"return",
"Path",
"(",
"filename",
")",
".",
"suffix",
"in",
"{",
"'.htm'",
",",
"'.html'",
",",
... | Returns True if the filename indicates that it should be escaped. | [
"Returns",
"True",
"if",
"the",
"filename",
"indicates",
"that",
"it",
"should",
"be",
"escaped",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L348-L352 |
231,729 | pgjones/quart | quart/app.py | Quart.update_template_context | async def update_template_context(self, context: dict) -> None:
"""Update the provided template context.
This adds additional context from the various template context
processors.
Arguments:
context: The context to update (mutate).
"""
processors = self.temp... | python | async def update_template_context(self, context: dict) -> None:
"""Update the provided template context.
This adds additional context from the various template context
processors.
Arguments:
context: The context to update (mutate).
"""
processors = self.temp... | [
"async",
"def",
"update_template_context",
"(",
"self",
",",
"context",
":",
"dict",
")",
"->",
"None",
":",
"processors",
"=",
"self",
".",
"template_context_processors",
"[",
"None",
"]",
"if",
"has_request_context",
"(",
")",
":",
"blueprint",
"=",
"_reques... | Update the provided template context.
This adds additional context from the various template context
processors.
Arguments:
context: The context to update (mutate). | [
"Update",
"the",
"provided",
"template",
"context",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L354-L373 |
231,730 | pgjones/quart | quart/app.py | Quart.make_shell_context | def make_shell_context(self) -> dict:
"""Create a context for interactive shell usage.
The :attr:`shell_context_processors` can be used to add
additional context.
"""
context = {'app': self, 'g': g}
for processor in self.shell_context_processors:
context.upda... | python | def make_shell_context(self) -> dict:
"""Create a context for interactive shell usage.
The :attr:`shell_context_processors` can be used to add
additional context.
"""
context = {'app': self, 'g': g}
for processor in self.shell_context_processors:
context.upda... | [
"def",
"make_shell_context",
"(",
"self",
")",
"->",
"dict",
":",
"context",
"=",
"{",
"'app'",
":",
"self",
",",
"'g'",
":",
"g",
"}",
"for",
"processor",
"in",
"self",
".",
"shell_context_processors",
":",
"context",
".",
"update",
"(",
"processor",
"(... | Create a context for interactive shell usage.
The :attr:`shell_context_processors` can be used to add
additional context. | [
"Create",
"a",
"context",
"for",
"interactive",
"shell",
"usage",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L375-L384 |
231,731 | pgjones/quart | quart/app.py | Quart.endpoint | def endpoint(self, endpoint: str) -> Callable:
"""Register a function as an endpoint.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.endpoint('name')
def endpoint():
...
Arguments:
endpoint... | python | def endpoint(self, endpoint: str) -> Callable:
"""Register a function as an endpoint.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.endpoint('name')
def endpoint():
...
Arguments:
endpoint... | [
"def",
"endpoint",
"(",
"self",
",",
"endpoint",
":",
"str",
")",
"->",
"Callable",
":",
"def",
"decorator",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"view_functions",
"[... | Register a function as an endpoint.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.endpoint('name')
def endpoint():
...
Arguments:
endpoint: The endpoint name to use. | [
"Register",
"a",
"function",
"as",
"an",
"endpoint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L638-L656 |
231,732 | pgjones/quart | quart/app.py | Quart.register_error_handler | def register_error_handler(
self, error: Union[Type[Exception], int], func: Callable, name: AppOrBlueprintKey=None,
) -> None:
"""Register a function as an error handler.
This is designed to be used on the application directly. An
example usage,
.. code-block:: python
... | python | def register_error_handler(
self, error: Union[Type[Exception], int], func: Callable, name: AppOrBlueprintKey=None,
) -> None:
"""Register a function as an error handler.
This is designed to be used on the application directly. An
example usage,
.. code-block:: python
... | [
"def",
"register_error_handler",
"(",
"self",
",",
"error",
":",
"Union",
"[",
"Type",
"[",
"Exception",
"]",
",",
"int",
"]",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
",",
")",
"->",
"None",
":",
"handler",
"="... | Register a function as an error handler.
This is designed to be used on the application directly. An
example usage,
.. code-block:: python
def error_handler():
return "Error", 500
app.register_error_handler(500, error_handler)
Arguments:
... | [
"Register",
"a",
"function",
"as",
"an",
"error",
"handler",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L677-L700 |
231,733 | pgjones/quart | quart/app.py | Quart.context_processor | def context_processor(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a template context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.context_processor
def update_context(context):
... | python | def context_processor(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a template context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.context_processor
def update_context(context):
... | [
"def",
"context_processor",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"self",
".",
"template_context_processors",
"[",
"name",
"]",
".",
"append",
"(",
"ensure_coroutine",
"(",
... | Add a template context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.context_processor
def update_context(context):
return context | [
"Add",
"a",
"template",
"context",
"processor",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L816-L829 |
231,734 | pgjones/quart | quart/app.py | Quart.shell_context_processor | def shell_context_processor(self, func: Callable) -> Callable:
"""Add a shell context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.shell_context_processor
def additional_context():
return context
... | python | def shell_context_processor(self, func: Callable) -> Callable:
"""Add a shell context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.shell_context_processor
def additional_context():
return context
... | [
"def",
"shell_context_processor",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"shell_context_processors",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Add a shell context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.shell_context_processor
def additional_context():
return context | [
"Add",
"a",
"shell",
"context",
"processor",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L831-L844 |
231,735 | pgjones/quart | quart/app.py | Quart.inject_url_defaults | def inject_url_defaults(self, endpoint: str, values: dict) -> None:
"""Injects default URL values into the passed values dict.
This is used to assist when building urls, see
:func:`~quart.helpers.url_for`.
"""
functions = self.url_value_preprocessors[None]
if '.' in endp... | python | def inject_url_defaults(self, endpoint: str, values: dict) -> None:
"""Injects default URL values into the passed values dict.
This is used to assist when building urls, see
:func:`~quart.helpers.url_for`.
"""
functions = self.url_value_preprocessors[None]
if '.' in endp... | [
"def",
"inject_url_defaults",
"(",
"self",
",",
"endpoint",
":",
"str",
",",
"values",
":",
"dict",
")",
"->",
"None",
":",
"functions",
"=",
"self",
".",
"url_value_preprocessors",
"[",
"None",
"]",
"if",
"'.'",
"in",
"endpoint",
":",
"blueprint",
"=",
... | Injects default URL values into the passed values dict.
This is used to assist when building urls, see
:func:`~quart.helpers.url_for`. | [
"Injects",
"default",
"URL",
"values",
"into",
"the",
"passed",
"values",
"dict",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L874-L886 |
231,736 | pgjones/quart | quart/app.py | Quart.handle_url_build_error | def handle_url_build_error(self, error: Exception, endpoint: str, values: dict) -> str:
"""Handle a build error.
Ideally this will return a valid url given the error endpoint
and values.
"""
for handler in self.url_build_error_handlers:
result = handler(error, endpoi... | python | def handle_url_build_error(self, error: Exception, endpoint: str, values: dict) -> str:
"""Handle a build error.
Ideally this will return a valid url given the error endpoint
and values.
"""
for handler in self.url_build_error_handlers:
result = handler(error, endpoi... | [
"def",
"handle_url_build_error",
"(",
"self",
",",
"error",
":",
"Exception",
",",
"endpoint",
":",
"str",
",",
"values",
":",
"dict",
")",
"->",
"str",
":",
"for",
"handler",
"in",
"self",
".",
"url_build_error_handlers",
":",
"result",
"=",
"handler",
"(... | Handle a build error.
Ideally this will return a valid url given the error endpoint
and values. | [
"Handle",
"a",
"build",
"error",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L888-L898 |
231,737 | pgjones/quart | quart/app.py | Quart.handle_http_exception | async def handle_http_exception(self, error: Exception) -> Response:
"""Handle a HTTPException subclass error.
This will attempt to find a handler for the error and if fails
will fall back to the error response.
"""
handler = self._find_exception_handler(error)
if handle... | python | async def handle_http_exception(self, error: Exception) -> Response:
"""Handle a HTTPException subclass error.
This will attempt to find a handler for the error and if fails
will fall back to the error response.
"""
handler = self._find_exception_handler(error)
if handle... | [
"async",
"def",
"handle_http_exception",
"(",
"self",
",",
"error",
":",
"Exception",
")",
"->",
"Response",
":",
"handler",
"=",
"self",
".",
"_find_exception_handler",
"(",
"error",
")",
"if",
"handler",
"is",
"None",
":",
"return",
"error",
".",
"get_resp... | Handle a HTTPException subclass error.
This will attempt to find a handler for the error and if fails
will fall back to the error response. | [
"Handle",
"a",
"HTTPException",
"subclass",
"error",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L914-L924 |
231,738 | pgjones/quart | quart/app.py | Quart.handle_user_exception | async def handle_user_exception(self, error: Exception) -> Response:
"""Handle an exception that has been raised.
This should forward :class:`~quart.exception.HTTPException` to
:meth:`handle_http_exception`, then attempt to handle the
error. If it cannot it should reraise the error.
... | python | async def handle_user_exception(self, error: Exception) -> Response:
"""Handle an exception that has been raised.
This should forward :class:`~quart.exception.HTTPException` to
:meth:`handle_http_exception`, then attempt to handle the
error. If it cannot it should reraise the error.
... | [
"async",
"def",
"handle_user_exception",
"(",
"self",
",",
"error",
":",
"Exception",
")",
"->",
"Response",
":",
"if",
"isinstance",
"(",
"error",
",",
"HTTPException",
")",
"and",
"not",
"self",
".",
"trap_http_exception",
"(",
"error",
")",
":",
"return",... | Handle an exception that has been raised.
This should forward :class:`~quart.exception.HTTPException` to
:meth:`handle_http_exception`, then attempt to handle the
error. If it cannot it should reraise the error. | [
"Handle",
"an",
"exception",
"that",
"has",
"been",
"raised",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L936-L949 |
231,739 | pgjones/quart | quart/app.py | Quart.before_request | def before_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a before request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_request
def func():
...
Argum... | python | def before_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a before request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_request
def func():
...
Argum... | [
"def",
"before_request",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"before_request_funcs",
"[",
"name",
"]",
... | Add a before request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_request
def func():
...
Arguments:
func: The before request function itself.
name: Optional blueprin... | [
"Add",
"a",
"before",
"request",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1007-L1024 |
231,740 | pgjones/quart | quart/app.py | Quart.before_websocket | def before_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a before websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_websocket
def func():
...
... | python | def before_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a before websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_websocket
def func():
...
... | [
"def",
"before_websocket",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"before_websocket_funcs",
"[",
"name",
"]... | Add a before websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_websocket
def func():
...
Arguments:
func: The before websocket function itself.
name: Optional bl... | [
"Add",
"a",
"before",
"websocket",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1026-L1043 |
231,741 | pgjones/quart | quart/app.py | Quart.before_serving | def before_serving(self, func: Callable) -> Callable:
"""Add a before serving function.
This will allow the function provided to be called once before
anything is served (before any byte is received).
This is designed to be used as a decorator. An example usage,
.. code-block:... | python | def before_serving(self, func: Callable) -> Callable:
"""Add a before serving function.
This will allow the function provided to be called once before
anything is served (before any byte is received).
This is designed to be used as a decorator. An example usage,
.. code-block:... | [
"def",
"before_serving",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"before_serving_funcs",
".",
"append",
"(",
"handler",
")",
"return",
"func"
] | Add a before serving function.
This will allow the function provided to be called once before
anything is served (before any byte is received).
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_serving
def func():... | [
"Add",
"a",
"before",
"serving",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1064-L1083 |
231,742 | pgjones/quart | quart/app.py | Quart.after_request | def after_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add an after request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_request
def func(response):
return respo... | python | def after_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add an after request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_request
def func(response):
return respo... | [
"def",
"after_request",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"after_request_funcs",
"[",
"name",
"]",
"... | Add an after request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_request
def func(response):
return response
Arguments:
func: The after request function itself.
name:... | [
"Add",
"an",
"after",
"request",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1085-L1102 |
231,743 | pgjones/quart | quart/app.py | Quart.after_websocket | def after_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add an after websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_websocket
def func(response):
return... | python | def after_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add an after websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_websocket
def func(response):
return... | [
"def",
"after_websocket",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"after_websocket_funcs",
"[",
"name",
"]",... | Add an after websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_websocket
def func(response):
return response
Arguments:
func: The after websocket function itself.
... | [
"Add",
"an",
"after",
"websocket",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1104-L1121 |
231,744 | pgjones/quart | quart/app.py | Quart.after_serving | def after_serving(self, func: Callable) -> Callable:
"""Add a after serving function.
This will allow the function provided to be called once after
anything is served (after last byte is sent).
This is designed to be used as a decorator. An example usage,
.. code-block:: pytho... | python | def after_serving(self, func: Callable) -> Callable:
"""Add a after serving function.
This will allow the function provided to be called once after
anything is served (after last byte is sent).
This is designed to be used as a decorator. An example usage,
.. code-block:: pytho... | [
"def",
"after_serving",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"after_serving_funcs",
".",
"append",
"(",
"handler",
")",
"return",
"func"
] | Add a after serving function.
This will allow the function provided to be called once after
anything is served (after last byte is sent).
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_serving
def func():
... | [
"Add",
"a",
"after",
"serving",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1123-L1143 |
231,745 | pgjones/quart | quart/app.py | Quart.teardown_request | def teardown_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_request
def func():
...
... | python | def teardown_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_request
def func():
...
... | [
"def",
"teardown_request",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"teardown_request_funcs",
"[",
"name",
"]... | Add a teardown request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_request
def func():
...
Arguments:
func: The teardown request function itself.
name: Optional bl... | [
"Add",
"a",
"teardown",
"request",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1145-L1162 |
231,746 | pgjones/quart | quart/app.py | Quart.teardown_websocket | def teardown_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_websocket
def func():
...
... | python | def teardown_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_websocket
def func():
...
... | [
"def",
"teardown_websocket",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"teardown_websocket_funcs",
"[",
"name",
... | Add a teardown websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_websocket
def func():
...
Arguments:
func: The teardown websocket function itself.
name: Optio... | [
"Add",
"a",
"teardown",
"websocket",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1164-L1181 |
231,747 | pgjones/quart | quart/app.py | Quart.register_blueprint | def register_blueprint(self, blueprint: Blueprint, url_prefix: Optional[str]=None) -> None:
"""Register a blueprint on the app.
This results in the blueprint's routes, error handlers
etc... being added to the app.
Arguments:
blueprint: The blueprint to register.
... | python | def register_blueprint(self, blueprint: Blueprint, url_prefix: Optional[str]=None) -> None:
"""Register a blueprint on the app.
This results in the blueprint's routes, error handlers
etc... being added to the app.
Arguments:
blueprint: The blueprint to register.
... | [
"def",
"register_blueprint",
"(",
"self",
",",
"blueprint",
":",
"Blueprint",
",",
"url_prefix",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"first_registration",
"=",
"False",
"if",
"blueprint",
".",
"name",
"in",
"self",
".",
... | Register a blueprint on the app.
This results in the blueprint's routes, error handlers
etc... being added to the app.
Arguments:
blueprint: The blueprint to register.
url_prefix: Optional prefix to apply to all paths. | [
"Register",
"a",
"blueprint",
"on",
"the",
"app",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1202-L1222 |
231,748 | pgjones/quart | quart/app.py | Quart.open_session | async def open_session(self, request: BaseRequestWebsocket) -> Session:
"""Open and return a Session using the request."""
return await ensure_coroutine(self.session_interface.open_session)(self, request) | python | async def open_session(self, request: BaseRequestWebsocket) -> Session:
"""Open and return a Session using the request."""
return await ensure_coroutine(self.session_interface.open_session)(self, request) | [
"async",
"def",
"open_session",
"(",
"self",
",",
"request",
":",
"BaseRequestWebsocket",
")",
"->",
"Session",
":",
"return",
"await",
"ensure_coroutine",
"(",
"self",
".",
"session_interface",
".",
"open_session",
")",
"(",
"self",
",",
"request",
")"
] | Open and return a Session using the request. | [
"Open",
"and",
"return",
"a",
"Session",
"using",
"the",
"request",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1228-L1230 |
231,749 | pgjones/quart | quart/app.py | Quart.save_session | async def save_session(self, session: Session, response: Response) -> None:
"""Saves the session to the response."""
await ensure_coroutine(self.session_interface.save_session)(self, session, response) | python | async def save_session(self, session: Session, response: Response) -> None:
"""Saves the session to the response."""
await ensure_coroutine(self.session_interface.save_session)(self, session, response) | [
"async",
"def",
"save_session",
"(",
"self",
",",
"session",
":",
"Session",
",",
"response",
":",
"Response",
")",
"->",
"None",
":",
"await",
"ensure_coroutine",
"(",
"self",
".",
"session_interface",
".",
"save_session",
")",
"(",
"self",
",",
"session",
... | Saves the session to the response. | [
"Saves",
"the",
"session",
"to",
"the",
"response",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1236-L1238 |
231,750 | pgjones/quart | quart/app.py | Quart.do_teardown_request | async def do_teardown_request(
self,
exc: Optional[BaseException],
request_context: Optional[RequestContext]=None,
) -> None:
"""Teardown the request, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the reques... | python | async def do_teardown_request(
self,
exc: Optional[BaseException],
request_context: Optional[RequestContext]=None,
) -> None:
"""Teardown the request, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the reques... | [
"async",
"def",
"do_teardown_request",
"(",
"self",
",",
"exc",
":",
"Optional",
"[",
"BaseException",
"]",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"request_",
"=",
"(",
"request_context"... | Teardown the request, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the request
to teardown.
request_context: The request context, optional as Flask
omits this argument. | [
"Teardown",
"the",
"request",
"calling",
"the",
"teardown",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1240-L1261 |
231,751 | pgjones/quart | quart/app.py | Quart.do_teardown_websocket | async def do_teardown_websocket(
self,
exc: Optional[BaseException],
websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Teardown the websocket, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused th... | python | async def do_teardown_websocket(
self,
exc: Optional[BaseException],
websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Teardown the websocket, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused th... | [
"async",
"def",
"do_teardown_websocket",
"(",
"self",
",",
"exc",
":",
"Optional",
"[",
"BaseException",
"]",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"websocket_",
"=",
"(",
"websocke... | Teardown the websocket, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the websocket
to teardown.
websocket_context: The websocket context, optional as Flask
omits this argument. | [
"Teardown",
"the",
"websocket",
"calling",
"the",
"teardown",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1263-L1284 |
231,752 | pgjones/quart | quart/app.py | Quart.run | def run(
self,
host: str='127.0.0.1',
port: int=5000,
debug: Optional[bool]=None,
use_reloader: bool=True,
loop: Optional[asyncio.AbstractEventLoop]=None,
ca_certs: Optional[str]=None,
certfile: Optional[str]=None,
... | python | def run(
self,
host: str='127.0.0.1',
port: int=5000,
debug: Optional[bool]=None,
use_reloader: bool=True,
loop: Optional[asyncio.AbstractEventLoop]=None,
ca_certs: Optional[str]=None,
certfile: Optional[str]=None,
... | [
"def",
"run",
"(",
"self",
",",
"host",
":",
"str",
"=",
"'127.0.0.1'",
",",
"port",
":",
"int",
"=",
"5000",
",",
"debug",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"use_reloader",
":",
"bool",
"=",
"True",
",",
"loop",
":",
"Optional",... | Run this application.
This is best used for development only, see Hypercorn for
production servers.
Arguments:
host: Hostname to listen on. By default this is loopback
only, use 0.0.0.0 to have the server listen externally.
port: Port number to listen on... | [
"Run",
"this",
"application",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1336-L1393 |
231,753 | pgjones/quart | quart/app.py | Quart.try_trigger_before_first_request_functions | async def try_trigger_before_first_request_functions(self) -> None:
"""Trigger the before first request methods."""
if self._got_first_request:
return
# Reverse the teardown functions, so as to match the expected usage
self.teardown_appcontext_funcs = list(reversed(self.tear... | python | async def try_trigger_before_first_request_functions(self) -> None:
"""Trigger the before first request methods."""
if self._got_first_request:
return
# Reverse the teardown functions, so as to match the expected usage
self.teardown_appcontext_funcs = list(reversed(self.tear... | [
"async",
"def",
"try_trigger_before_first_request_functions",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_got_first_request",
":",
"return",
"# Reverse the teardown functions, so as to match the expected usage",
"self",
".",
"teardown_appcontext_funcs",
"=",
"li... | Trigger the before first request methods. | [
"Trigger",
"the",
"before",
"first",
"request",
"methods",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1437-L1454 |
231,754 | pgjones/quart | quart/app.py | Quart.make_default_options_response | async def make_default_options_response(self) -> Response:
"""This is the default route function for OPTIONS requests."""
methods = _request_ctx_stack.top.url_adapter.allowed_methods()
return self.response_class('', headers={'Allow': ', '.join(methods)}) | python | async def make_default_options_response(self) -> Response:
"""This is the default route function for OPTIONS requests."""
methods = _request_ctx_stack.top.url_adapter.allowed_methods()
return self.response_class('', headers={'Allow': ', '.join(methods)}) | [
"async",
"def",
"make_default_options_response",
"(",
"self",
")",
"->",
"Response",
":",
"methods",
"=",
"_request_ctx_stack",
".",
"top",
".",
"url_adapter",
".",
"allowed_methods",
"(",
")",
"return",
"self",
".",
"response_class",
"(",
"''",
",",
"headers",
... | This is the default route function for OPTIONS requests. | [
"This",
"is",
"the",
"default",
"route",
"function",
"for",
"OPTIONS",
"requests",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1456-L1459 |
231,755 | pgjones/quart | quart/app.py | Quart.make_response | async def make_response(self, result: ResponseReturnValue) -> Response:
"""Make a Response from the result of the route handler.
The result itself can either be:
- A Response object (or subclass).
- A tuple of a ResponseValue and a header dictionary.
- A tuple of a Respons... | python | async def make_response(self, result: ResponseReturnValue) -> Response:
"""Make a Response from the result of the route handler.
The result itself can either be:
- A Response object (or subclass).
- A tuple of a ResponseValue and a header dictionary.
- A tuple of a Respons... | [
"async",
"def",
"make_response",
"(",
"self",
",",
"result",
":",
"ResponseReturnValue",
")",
"->",
"Response",
":",
"status_or_headers",
"=",
"None",
"headers",
"=",
"None",
"status",
"=",
"None",
"if",
"isinstance",
"(",
"result",
",",
"tuple",
")",
":",
... | Make a Response from the result of the route handler.
The result itself can either be:
- A Response object (or subclass).
- A tuple of a ResponseValue and a header dictionary.
- A tuple of a ResponseValue, status code and a header dictionary.
A ResponseValue is either a R... | [
"Make",
"a",
"Response",
"from",
"the",
"result",
"of",
"the",
"route",
"handler",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1461-L1501 |
231,756 | pgjones/quart | quart/app.py | Quart.full_dispatch_request | async def full_dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> Response:
"""Adds pre and post processing to the request dispatching.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
... | python | async def full_dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> Response:
"""Adds pre and post processing to the request dispatching.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
... | [
"async",
"def",
"full_dispatch_request",
"(",
"self",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"Response",
":",
"await",
"self",
".",
"try_trigger_before_first_request_functions",
"(",
")",
"await",
"request... | Adds pre and post processing to the request dispatching.
Arguments:
request_context: The request context, optional as Flask
omits this argument. | [
"Adds",
"pre",
"and",
"post",
"processing",
"to",
"the",
"request",
"dispatching",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1512-L1529 |
231,757 | pgjones/quart | quart/app.py | Quart.preprocess_request | async def preprocess_request(
self, request_context: Optional[RequestContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the request i.e. call before_request functions.
Arguments:
request_context: The request context, optional as Flask
omits this arg... | python | async def preprocess_request(
self, request_context: Optional[RequestContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the request i.e. call before_request functions.
Arguments:
request_context: The request context, optional as Flask
omits this arg... | [
"async",
"def",
"preprocess_request",
"(",
"self",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"ResponseReturnValue",
"]",
":",
"request_",
"=",
"(",
"request_context",
"or",
"_request_ctx_st... | Preprocess the request i.e. call before_request functions.
Arguments:
request_context: The request context, optional as Flask
omits this argument. | [
"Preprocess",
"the",
"request",
"i",
".",
"e",
".",
"call",
"before_request",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1531-L1555 |
231,758 | pgjones/quart | quart/app.py | Quart.dispatch_request | async def dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> ResponseReturnValue:
"""Dispatch the request to the view function.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
r... | python | async def dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> ResponseReturnValue:
"""Dispatch the request to the view function.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
r... | [
"async",
"def",
"dispatch_request",
"(",
"self",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"ResponseReturnValue",
":",
"request_",
"=",
"(",
"request_context",
"or",
"_request_ctx_stack",
".",
"top",
")",
... | Dispatch the request to the view function.
Arguments:
request_context: The request context, optional as Flask
omits this argument. | [
"Dispatch",
"the",
"request",
"to",
"the",
"view",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1557-L1574 |
231,759 | pgjones/quart | quart/app.py | Quart.process_response | async def process_response(
self,
response: Response,
request_context: Optional[RequestContext]=None,
) -> Response:
"""Postprocess the request acting on the response.
Arguments:
response: The response after the request is finalized.
request_context: ... | python | async def process_response(
self,
response: Response,
request_context: Optional[RequestContext]=None,
) -> Response:
"""Postprocess the request acting on the response.
Arguments:
response: The response after the request is finalized.
request_context: ... | [
"async",
"def",
"process_response",
"(",
"self",
",",
"response",
":",
"Response",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"Response",
":",
"request_",
"=",
"(",
"request_context",
"or",
"_request_ctx_s... | Postprocess the request acting on the response.
Arguments:
response: The response after the request is finalized.
request_context: The request context, optional as Flask
omits this argument. | [
"Postprocess",
"the",
"request",
"acting",
"on",
"the",
"response",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1599-L1624 |
231,760 | pgjones/quart | quart/app.py | Quart.full_dispatch_websocket | async def full_dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[Response]:
"""Adds pre and post processing to the websocket dispatching.
Arguments:
websocket_context: The websocket context, optional to match
the Flask co... | python | async def full_dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[Response]:
"""Adds pre and post processing to the websocket dispatching.
Arguments:
websocket_context: The websocket context, optional to match
the Flask co... | [
"async",
"def",
"full_dispatch_websocket",
"(",
"self",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"Response",
"]",
":",
"await",
"self",
".",
"try_trigger_before_first_request_functions",
... | Adds pre and post processing to the websocket dispatching.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention. | [
"Adds",
"pre",
"and",
"post",
"processing",
"to",
"the",
"websocket",
"dispatching",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1635-L1652 |
231,761 | pgjones/quart | quart/app.py | Quart.preprocess_websocket | async def preprocess_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the websocket i.e. call before_websocket functions.
Arguments:
websocket_context: The websocket context, optional as Flask
... | python | async def preprocess_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the websocket i.e. call before_websocket functions.
Arguments:
websocket_context: The websocket context, optional as Flask
... | [
"async",
"def",
"preprocess_websocket",
"(",
"self",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"ResponseReturnValue",
"]",
":",
"websocket_",
"=",
"(",
"websocket_context",
"or",
"_webs... | Preprocess the websocket i.e. call before_websocket functions.
Arguments:
websocket_context: The websocket context, optional as Flask
omits this argument. | [
"Preprocess",
"the",
"websocket",
"i",
".",
"e",
".",
"call",
"before_websocket",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1654-L1678 |
231,762 | pgjones/quart | quart/app.py | Quart.dispatch_websocket | async def dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Dispatch the websocket to the view function.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention.
"""
web... | python | async def dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Dispatch the websocket to the view function.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention.
"""
web... | [
"async",
"def",
"dispatch_websocket",
"(",
"self",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"websocket_",
"=",
"(",
"websocket_context",
"or",
"_websocket_ctx_stack",
".",
"top",
")",
".... | Dispatch the websocket to the view function.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention. | [
"Dispatch",
"the",
"websocket",
"to",
"the",
"view",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1680-L1694 |
231,763 | pgjones/quart | quart/app.py | Quart.postprocess_websocket | async def postprocess_websocket(
self,
response: Optional[Response],
websocket_context: Optional[WebsocketContext]=None,
) -> Response:
"""Postprocess the websocket acting on the response.
Arguments:
response: The response after the websocket is finalized.
... | python | async def postprocess_websocket(
self,
response: Optional[Response],
websocket_context: Optional[WebsocketContext]=None,
) -> Response:
"""Postprocess the websocket acting on the response.
Arguments:
response: The response after the websocket is finalized.
... | [
"async",
"def",
"postprocess_websocket",
"(",
"self",
",",
"response",
":",
"Optional",
"[",
"Response",
"]",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"Response",
":",
"websocket_",
"=",
"(",
"webs... | Postprocess the websocket acting on the response.
Arguments:
response: The response after the websocket is finalized.
webcoket_context: The websocket context, optional as Flask
omits this argument. | [
"Postprocess",
"the",
"websocket",
"acting",
"on",
"the",
"response",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1722-L1753 |
231,764 | pgjones/quart | quart/ctx.py | after_this_request | def after_this_request(func: Callable) -> Callable:
"""Schedule the func to be called after the current request.
This is useful in situations whereby you want an after request
function for a specific route or circumstance only, for example,
.. code-block:: python
def index():
@aft... | python | def after_this_request(func: Callable) -> Callable:
"""Schedule the func to be called after the current request.
This is useful in situations whereby you want an after request
function for a specific route or circumstance only, for example,
.. code-block:: python
def index():
@aft... | [
"def",
"after_this_request",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"_request_ctx_stack",
".",
"top",
".",
"_after_request_functions",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Schedule the func to be called after the current request.
This is useful in situations whereby you want an after request
function for a specific route or circumstance only, for example,
.. code-block:: python
def index():
@after_this_request
def set_cookie(response):
... | [
"Schedule",
"the",
"func",
"to",
"be",
"called",
"after",
"the",
"current",
"request",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L183-L200 |
231,765 | pgjones/quart | quart/ctx.py | after_this_websocket | def after_this_websocket(func: Callable) -> Callable:
"""Schedule the func to be called after the current websocket.
This is useful in situations whereby you want an after websocket
function for a specific route or circumstance only, for example,
.. note::
The response is an optional argument,... | python | def after_this_websocket(func: Callable) -> Callable:
"""Schedule the func to be called after the current websocket.
This is useful in situations whereby you want an after websocket
function for a specific route or circumstance only, for example,
.. note::
The response is an optional argument,... | [
"def",
"after_this_websocket",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"_websocket_ctx_stack",
".",
"top",
".",
"_after_websocket_functions",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Schedule the func to be called after the current websocket.
This is useful in situations whereby you want an after websocket
function for a specific route or circumstance only, for example,
.. note::
The response is an optional argument, and will only be
passed if the websocket was not act... | [
"Schedule",
"the",
"func",
"to",
"be",
"called",
"after",
"the",
"current",
"websocket",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L203-L226 |
231,766 | pgjones/quart | quart/ctx.py | copy_current_app_context | def copy_current_app_context(func: Callable) -> Callable:
"""Share the current app context with the function decorated.
The app context is local per task and hence will not be available
in any other task. This decorator can be used to make the context
available,
.. code-block:: python
@co... | python | def copy_current_app_context(func: Callable) -> Callable:
"""Share the current app context with the function decorated.
The app context is local per task and hence will not be available
in any other task. This decorator can be used to make the context
available,
.. code-block:: python
@co... | [
"def",
"copy_current_app_context",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"if",
"not",
"has_app_context",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'Attempt to copy app context outside of a app context'",
")",
"app_context",
"=",
"_app_ctx_stack",... | Share the current app context with the function decorated.
The app context is local per task and hence will not be available
in any other task. This decorator can be used to make the context
available,
.. code-block:: python
@copy_current_app_context
async def within_context() -> None... | [
"Share",
"the",
"current",
"app",
"context",
"with",
"the",
"function",
"decorated",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L229-L253 |
231,767 | pgjones/quart | quart/ctx.py | copy_current_request_context | def copy_current_request_context(func: Callable) -> Callable:
"""Share the current request context with the function decorated.
The request context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
... | python | def copy_current_request_context(func: Callable) -> Callable:
"""Share the current request context with the function decorated.
The request context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
... | [
"def",
"copy_current_request_context",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"if",
"not",
"has_request_context",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'Attempt to copy request context outside of a request context'",
")",
"request_context",
"=",... | Share the current request context with the function decorated.
The request context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
@copy_current_request_context
async def within_conte... | [
"Share",
"the",
"current",
"request",
"context",
"with",
"the",
"function",
"decorated",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L256-L280 |
231,768 | pgjones/quart | quart/ctx.py | copy_current_websocket_context | def copy_current_websocket_context(func: Callable) -> Callable:
"""Share the current websocket context with the function decorated.
The websocket context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: p... | python | def copy_current_websocket_context(func: Callable) -> Callable:
"""Share the current websocket context with the function decorated.
The websocket context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: p... | [
"def",
"copy_current_websocket_context",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"if",
"not",
"has_websocket_context",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'Attempt to copy websocket context outside of a websocket context'",
")",
"websocket_contex... | Share the current websocket context with the function decorated.
The websocket context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
@copy_current_websocket_context
async def within... | [
"Share",
"the",
"current",
"websocket",
"context",
"with",
"the",
"function",
"decorated",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L283-L307 |
231,769 | pgjones/quart | quart/ctx.py | _BaseRequestWebsocketContext.match_request | def match_request(self) -> None:
"""Match the request against the adapter.
Override this method to configure request matching, it should
set the request url_rule and view_args and optionally a
routing_exception.
"""
try:
self.request_websocket.url_rule, self.... | python | def match_request(self) -> None:
"""Match the request against the adapter.
Override this method to configure request matching, it should
set the request url_rule and view_args and optionally a
routing_exception.
"""
try:
self.request_websocket.url_rule, self.... | [
"def",
"match_request",
"(",
"self",
")",
"->",
"None",
":",
"try",
":",
"self",
".",
"request_websocket",
".",
"url_rule",
",",
"self",
".",
"request_websocket",
".",
"view_args",
"=",
"self",
".",
"url_adapter",
".",
"match",
"(",
")",
"# noqa",
"except"... | Match the request against the adapter.
Override this method to configure request matching, it should
set the request url_rule and view_args and optionally a
routing_exception. | [
"Match",
"the",
"request",
"against",
"the",
"adapter",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L37-L47 |
231,770 | pgjones/quart | quart/ctx.py | _AppCtxGlobals.get | def get(self, name: str, default: Optional[Any]=None) -> Any:
"""Get a named attribute of this instance, or return the default."""
return self.__dict__.get(name, default) | python | def get(self, name: str, default: Optional[Any]=None) -> Any:
"""Get a named attribute of this instance, or return the default."""
return self.__dict__.get(name, default) | [
"def",
"get",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
")",
"->",
"Any",
":",
"return",
"self",
".",
"__dict__",
".",
"get",
"(",
"name",
",",
"default",
")"
] | Get a named attribute of this instance, or return the default. | [
"Get",
"a",
"named",
"attribute",
"of",
"this",
"instance",
"or",
"return",
"the",
"default",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L364-L366 |
231,771 | pgjones/quart | quart/ctx.py | _AppCtxGlobals.pop | def pop(self, name: str, default: Any=_sentinel) -> Any:
"""Pop, get and remove the named attribute of this instance."""
if default is _sentinel:
return self.__dict__.pop(name)
else:
return self.__dict__.pop(name, default) | python | def pop(self, name: str, default: Any=_sentinel) -> Any:
"""Pop, get and remove the named attribute of this instance."""
if default is _sentinel:
return self.__dict__.pop(name)
else:
return self.__dict__.pop(name, default) | [
"def",
"pop",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"_sentinel",
")",
"->",
"Any",
":",
"if",
"default",
"is",
"_sentinel",
":",
"return",
"self",
".",
"__dict__",
".",
"pop",
"(",
"name",
")",
"else",
":",
"return"... | Pop, get and remove the named attribute of this instance. | [
"Pop",
"get",
"and",
"remove",
"the",
"named",
"attribute",
"of",
"this",
"instance",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L368-L373 |
231,772 | pgjones/quart | quart/ctx.py | _AppCtxGlobals.setdefault | def setdefault(self, name: str, default: Any=None) -> Any:
"""Set an attribute with a default value."""
return self.__dict__.setdefault(name, default) | python | def setdefault(self, name: str, default: Any=None) -> Any:
"""Set an attribute with a default value."""
return self.__dict__.setdefault(name, default) | [
"def",
"setdefault",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"None",
")",
"->",
"Any",
":",
"return",
"self",
".",
"__dict__",
".",
"setdefault",
"(",
"name",
",",
"default",
")"
] | Set an attribute with a default value. | [
"Set",
"an",
"attribute",
"with",
"a",
"default",
"value",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L375-L377 |
231,773 | pgjones/quart | quart/sessions.py | SessionInterface.get_cookie_domain | def get_cookie_domain(self, app: 'Quart') -> Optional[str]:
"""Helper method to return the Cookie Domain for the App."""
if app.config['SESSION_COOKIE_DOMAIN'] is not None:
return app.config['SESSION_COOKIE_DOMAIN']
elif app.config['SERVER_NAME'] is not None:
return '.' +... | python | def get_cookie_domain(self, app: 'Quart') -> Optional[str]:
"""Helper method to return the Cookie Domain for the App."""
if app.config['SESSION_COOKIE_DOMAIN'] is not None:
return app.config['SESSION_COOKIE_DOMAIN']
elif app.config['SERVER_NAME'] is not None:
return '.' +... | [
"def",
"get_cookie_domain",
"(",
"self",
",",
"app",
":",
"'Quart'",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"app",
".",
"config",
"[",
"'SESSION_COOKIE_DOMAIN'",
"]",
"is",
"not",
"None",
":",
"return",
"app",
".",
"config",
"[",
"'SESSION_CO... | Helper method to return the Cookie Domain for the App. | [
"Helper",
"method",
"to",
"return",
"the",
"Cookie",
"Domain",
"for",
"the",
"App",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L129-L136 |
231,774 | pgjones/quart | quart/sessions.py | SessionInterface.get_expiration_time | def get_expiration_time(self, app: 'Quart', session: SessionMixin) -> Optional[datetime]:
"""Helper method to return the Session expiration time.
If the session is not 'permanent' it will expire as and when
the browser stops accessing the app.
"""
if session.permanent:
... | python | def get_expiration_time(self, app: 'Quart', session: SessionMixin) -> Optional[datetime]:
"""Helper method to return the Session expiration time.
If the session is not 'permanent' it will expire as and when
the browser stops accessing the app.
"""
if session.permanent:
... | [
"def",
"get_expiration_time",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"session",
":",
"SessionMixin",
")",
"->",
"Optional",
"[",
"datetime",
"]",
":",
"if",
"session",
".",
"permanent",
":",
"return",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"app... | Helper method to return the Session expiration time.
If the session is not 'permanent' it will expire as and when
the browser stops accessing the app. | [
"Helper",
"method",
"to",
"return",
"the",
"Session",
"expiration",
"time",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L150-L159 |
231,775 | pgjones/quart | quart/sessions.py | SessionInterface.should_set_cookie | def should_set_cookie(self, app: 'Quart', session: SessionMixin) -> bool:
"""Helper method to return if the Set Cookie header should be present.
This triggers if the session is marked as modified or the app
is configured to always refresh the cookie.
"""
if session.modified:
... | python | def should_set_cookie(self, app: 'Quart', session: SessionMixin) -> bool:
"""Helper method to return if the Set Cookie header should be present.
This triggers if the session is marked as modified or the app
is configured to always refresh the cookie.
"""
if session.modified:
... | [
"def",
"should_set_cookie",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"session",
":",
"SessionMixin",
")",
"->",
"bool",
":",
"if",
"session",
".",
"modified",
":",
"return",
"True",
"save_each",
"=",
"app",
".",
"config",
"[",
"'SESSION_REFRESH_EACH_REQ... | Helper method to return if the Set Cookie header should be present.
This triggers if the session is marked as modified or the app
is configured to always refresh the cookie. | [
"Helper",
"method",
"to",
"return",
"if",
"the",
"Set",
"Cookie",
"header",
"should",
"be",
"present",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L161-L170 |
231,776 | pgjones/quart | quart/sessions.py | SecureCookieSessionInterface.get_signing_serializer | def get_signing_serializer(self, app: 'Quart') -> Optional[URLSafeTimedSerializer]:
"""Return a serializer for the session that also signs data.
This will return None if the app is not configured for secrets.
"""
if not app.secret_key:
return None
options = {
... | python | def get_signing_serializer(self, app: 'Quart') -> Optional[URLSafeTimedSerializer]:
"""Return a serializer for the session that also signs data.
This will return None if the app is not configured for secrets.
"""
if not app.secret_key:
return None
options = {
... | [
"def",
"get_signing_serializer",
"(",
"self",
",",
"app",
":",
"'Quart'",
")",
"->",
"Optional",
"[",
"URLSafeTimedSerializer",
"]",
":",
"if",
"not",
"app",
".",
"secret_key",
":",
"return",
"None",
"options",
"=",
"{",
"'key_derivation'",
":",
"self",
".",... | Return a serializer for the session that also signs data.
This will return None if the app is not configured for secrets. | [
"Return",
"a",
"serializer",
"for",
"the",
"session",
"that",
"also",
"signs",
"data",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L204-L218 |
231,777 | pgjones/quart | quart/sessions.py | SecureCookieSessionInterface.open_session | async def open_session(
self,
app: 'Quart',
request: BaseRequestWebsocket,
) -> Optional[SecureCookieSession]:
"""Open a secure cookie based session.
This will return None if a signing serializer is not availabe,
usually if the config SECRET_KEY is not se... | python | async def open_session(
self,
app: 'Quart',
request: BaseRequestWebsocket,
) -> Optional[SecureCookieSession]:
"""Open a secure cookie based session.
This will return None if a signing serializer is not availabe,
usually if the config SECRET_KEY is not se... | [
"async",
"def",
"open_session",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"request",
":",
"BaseRequestWebsocket",
",",
")",
"->",
"Optional",
"[",
"SecureCookieSession",
"]",
":",
"signer",
"=",
"self",
".",
"get_signing_serializer",
"(",
"app",
")",
"if... | Open a secure cookie based session.
This will return None if a signing serializer is not availabe,
usually if the config SECRET_KEY is not set. | [
"Open",
"a",
"secure",
"cookie",
"based",
"session",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L220-L243 |
231,778 | pgjones/quart | quart/sessions.py | SecureCookieSessionInterface.save_session | async def save_session( # type: ignore
self, app: 'Quart', session: SecureCookieSession, response: Response,
) -> None:
"""Saves the session to the response in a secure cookie."""
domain = self.get_cookie_domain(app)
path = self.get_cookie_path(app)
if not session:
... | python | async def save_session( # type: ignore
self, app: 'Quart', session: SecureCookieSession, response: Response,
) -> None:
"""Saves the session to the response in a secure cookie."""
domain = self.get_cookie_domain(app)
path = self.get_cookie_path(app)
if not session:
... | [
"async",
"def",
"save_session",
"(",
"# type: ignore",
"self",
",",
"app",
":",
"'Quart'",
",",
"session",
":",
"SecureCookieSession",
",",
"response",
":",
"Response",
",",
")",
"->",
"None",
":",
"domain",
"=",
"self",
".",
"get_cookie_domain",
"(",
"app",... | Saves the session to the response in a secure cookie. | [
"Saves",
"the",
"session",
"to",
"the",
"response",
"in",
"a",
"secure",
"cookie",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L245-L271 |
231,779 | pgjones/quart | quart/wrappers/response.py | Response.get_data | async def get_data(self, raw: bool=True) -> AnyStr:
"""Return the body data."""
if self.implicit_sequence_conversion:
self.response = self.data_body_class(await self.response.convert_to_sequence())
result = b'' if raw else ''
async with self.response as body: # type: ignore
... | python | async def get_data(self, raw: bool=True) -> AnyStr:
"""Return the body data."""
if self.implicit_sequence_conversion:
self.response = self.data_body_class(await self.response.convert_to_sequence())
result = b'' if raw else ''
async with self.response as body: # type: ignore
... | [
"async",
"def",
"get_data",
"(",
"self",
",",
"raw",
":",
"bool",
"=",
"True",
")",
"->",
"AnyStr",
":",
"if",
"self",
".",
"implicit_sequence_conversion",
":",
"self",
".",
"response",
"=",
"self",
".",
"data_body_class",
"(",
"await",
"self",
".",
"res... | Return the body data. | [
"Return",
"the",
"body",
"data",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L272-L283 |
231,780 | pgjones/quart | quart/wrappers/response.py | Response.set_data | def set_data(self, data: AnyStr) -> None:
"""Set the response data.
This will encode using the :attr:`charset`.
"""
if isinstance(data, str):
bytes_data = data.encode(self.charset)
else:
bytes_data = data
self.response = self.data_body_class(bytes... | python | def set_data(self, data: AnyStr) -> None:
"""Set the response data.
This will encode using the :attr:`charset`.
"""
if isinstance(data, str):
bytes_data = data.encode(self.charset)
else:
bytes_data = data
self.response = self.data_body_class(bytes... | [
"def",
"set_data",
"(",
"self",
",",
"data",
":",
"AnyStr",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"bytes_data",
"=",
"data",
".",
"encode",
"(",
"self",
".",
"charset",
")",
"else",
":",
"bytes_data",
"=",
"... | Set the response data.
This will encode using the :attr:`charset`. | [
"Set",
"the",
"response",
"data",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L285-L296 |
231,781 | pgjones/quart | quart/wrappers/response.py | Response.make_conditional | async def make_conditional(
self,
request_range: Range,
max_partial_size: Optional[int]=None,
) -> None:
"""Make the response conditional to the
Arguments:
request_range: The range as requested by the request.
max_partial_size: The maximum... | python | async def make_conditional(
self,
request_range: Range,
max_partial_size: Optional[int]=None,
) -> None:
"""Make the response conditional to the
Arguments:
request_range: The range as requested by the request.
max_partial_size: The maximum... | [
"async",
"def",
"make_conditional",
"(",
"self",
",",
"request_range",
":",
"Range",
",",
"max_partial_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"self",
".",
"accept_ranges",
"=",
"\"bytes\"",
"# Advertise this ability"... | Make the response conditional to the
Arguments:
request_range: The range as requested by the request.
max_partial_size: The maximum length the server is willing
to serve in a single response. Defaults to unlimited. | [
"Make",
"the",
"response",
"conditional",
"to",
"the"
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L298-L335 |
231,782 | pgjones/quart | quart/wrappers/response.py | Response.set_cookie | def set_cookie( # type: ignore
self,
key: str,
value: AnyStr='',
max_age: Optional[Union[int, timedelta]]=None,
expires: Optional[datetime]=None,
path: str='/',
domain: Optional[str]=None,
secure: bool=False,
ht... | python | def set_cookie( # type: ignore
self,
key: str,
value: AnyStr='',
max_age: Optional[Union[int, timedelta]]=None,
expires: Optional[datetime]=None,
path: str='/',
domain: Optional[str]=None,
secure: bool=False,
ht... | [
"def",
"set_cookie",
"(",
"# type: ignore",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"AnyStr",
"=",
"''",
",",
"max_age",
":",
"Optional",
"[",
"Union",
"[",
"int",
",",
"timedelta",
"]",
"]",
"=",
"None",
",",
"expires",
":",
"Optional",
"... | Set a cookie in the response headers.
The arguments are the standard cookie morsels and this is a
wrapper around the stdlib SimpleCookie code. | [
"Set",
"a",
"cookie",
"in",
"the",
"response",
"headers",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L341-L360 |
231,783 | pgjones/quart | quart/routing.py | Rule.match | def match(self, path: str) -> Tuple[Optional[Dict[str, Any]], bool]:
"""Check if the path matches this Rule.
If it does it returns a dict of matched and converted values,
otherwise None is returned.
"""
match = self._pattern.match(path)
if match is not None:
... | python | def match(self, path: str) -> Tuple[Optional[Dict[str, Any]], bool]:
"""Check if the path matches this Rule.
If it does it returns a dict of matched and converted values,
otherwise None is returned.
"""
match = self._pattern.match(path)
if match is not None:
... | [
"def",
"match",
"(",
"self",
",",
"path",
":",
"str",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"bool",
"]",
":",
"match",
"=",
"self",
".",
"_pattern",
".",
"match",
"(",
"path",
")",
"if",
"match... | Check if the path matches this Rule.
If it does it returns a dict of matched and converted values,
otherwise None is returned. | [
"Check",
"if",
"the",
"path",
"matches",
"this",
"Rule",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L335-L360 |
231,784 | pgjones/quart | quart/routing.py | Rule.provides_defaults_for | def provides_defaults_for(self, rule: 'Rule', **values: Any) -> bool:
"""Returns true if this rule provides defaults for the argument and values."""
defaults_match = all(
values[key] == self.defaults[key] for key in self.defaults if key in values # noqa: S101, E501
)
return ... | python | def provides_defaults_for(self, rule: 'Rule', **values: Any) -> bool:
"""Returns true if this rule provides defaults for the argument and values."""
defaults_match = all(
values[key] == self.defaults[key] for key in self.defaults if key in values # noqa: S101, E501
)
return ... | [
"def",
"provides_defaults_for",
"(",
"self",
",",
"rule",
":",
"'Rule'",
",",
"*",
"*",
"values",
":",
"Any",
")",
"->",
"bool",
":",
"defaults_match",
"=",
"all",
"(",
"values",
"[",
"key",
"]",
"==",
"self",
".",
"defaults",
"[",
"key",
"]",
"for",... | Returns true if this rule provides defaults for the argument and values. | [
"Returns",
"true",
"if",
"this",
"rule",
"provides",
"defaults",
"for",
"the",
"argument",
"and",
"values",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L362-L367 |
231,785 | pgjones/quart | quart/routing.py | Rule.build | def build(self, **values: Any) -> str:
"""Build this rule into a path using the values given."""
converted_values = {
key: self._converters[key].to_url(value)
for key, value in values.items()
if key in self._converters
}
result = self._builder.format(*... | python | def build(self, **values: Any) -> str:
"""Build this rule into a path using the values given."""
converted_values = {
key: self._converters[key].to_url(value)
for key, value in values.items()
if key in self._converters
}
result = self._builder.format(*... | [
"def",
"build",
"(",
"self",
",",
"*",
"*",
"values",
":",
"Any",
")",
"->",
"str",
":",
"converted_values",
"=",
"{",
"key",
":",
"self",
".",
"_converters",
"[",
"key",
"]",
".",
"to_url",
"(",
"value",
")",
"for",
"key",
",",
"value",
"in",
"v... | Build this rule into a path using the values given. | [
"Build",
"this",
"rule",
"into",
"a",
"path",
"using",
"the",
"values",
"given",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L369-L387 |
231,786 | pgjones/quart | quart/routing.py | Rule.buildable | def buildable(self, values: Optional[dict]=None, method: Optional[str]=None) -> bool:
"""Return True if this rule can build with the values and method."""
if method is not None and method not in self.methods:
return False
defaults_match = all(
values[key] == self.defaults... | python | def buildable(self, values: Optional[dict]=None, method: Optional[str]=None) -> bool:
"""Return True if this rule can build with the values and method."""
if method is not None and method not in self.methods:
return False
defaults_match = all(
values[key] == self.defaults... | [
"def",
"buildable",
"(",
"self",
",",
"values",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
",",
"method",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"method",
"is",
"not",
"None",
"and",
"method",
"not",
"in",... | Return True if this rule can build with the values and method. | [
"Return",
"True",
"if",
"this",
"rule",
"can",
"build",
"with",
"the",
"values",
"and",
"method",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L389-L396 |
231,787 | pgjones/quart | quart/routing.py | Rule.bind | def bind(self, map: Map) -> None:
"""Bind the Rule to a Map and compile it."""
if self.map is not None:
raise RuntimeError(f"{self!r} is already bound to {self.map!r}")
self.map = map
pattern = ''
builder = ''
full_rule = "{}\\|{}".format(self.host or '', se... | python | def bind(self, map: Map) -> None:
"""Bind the Rule to a Map and compile it."""
if self.map is not None:
raise RuntimeError(f"{self!r} is already bound to {self.map!r}")
self.map = map
pattern = ''
builder = ''
full_rule = "{}\\|{}".format(self.host or '', se... | [
"def",
"bind",
"(",
"self",
",",
"map",
":",
"Map",
")",
"->",
"None",
":",
"if",
"self",
".",
"map",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"{self!r} is already bound to {self.map!r}\"",
")",
"self",
".",
"map",
"=",
"map",
"pattern",
... | Bind the Rule to a Map and compile it. | [
"Bind",
"the",
"Rule",
"to",
"a",
"Map",
"and",
"compile",
"it",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L398-L427 |
231,788 | pgjones/quart | quart/routing.py | Rule.match_key | def match_key(self) -> Tuple[bool, bool, int, List[WeightedPart]]:
"""A Key to sort the rules by weight for matching.
The key leads to ordering:
- By first order by defaults as they are simple rules without
conversions.
- Then on the complexity of the rule, i.e. does it ha... | python | def match_key(self) -> Tuple[bool, bool, int, List[WeightedPart]]:
"""A Key to sort the rules by weight for matching.
The key leads to ordering:
- By first order by defaults as they are simple rules without
conversions.
- Then on the complexity of the rule, i.e. does it ha... | [
"def",
"match_key",
"(",
"self",
")",
"->",
"Tuple",
"[",
"bool",
",",
"bool",
",",
"int",
",",
"List",
"[",
"WeightedPart",
"]",
"]",
":",
"if",
"self",
".",
"map",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"{self!r} is not bound to a Map\"",
... | A Key to sort the rules by weight for matching.
The key leads to ordering:
- By first order by defaults as they are simple rules without
conversions.
- Then on the complexity of the rule, i.e. does it have any
converted parts. This is as simple rules are quick to match
... | [
"A",
"Key",
"to",
"sort",
"the",
"rules",
"by",
"weight",
"for",
"matching",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L430-L448 |
231,789 | pgjones/quart | quart/routing.py | Rule.build_key | def build_key(self) -> Tuple[bool, int]:
"""A Key to sort the rules by weight for building.
The key leads to ordering:
- By routes with defaults first, as these must be evaulated
for building before ones without.
- Then the more complex routes (most converted parts).
... | python | def build_key(self) -> Tuple[bool, int]:
"""A Key to sort the rules by weight for building.
The key leads to ordering:
- By routes with defaults first, as these must be evaulated
for building before ones without.
- Then the more complex routes (most converted parts).
... | [
"def",
"build_key",
"(",
"self",
")",
"->",
"Tuple",
"[",
"bool",
",",
"int",
"]",
":",
"if",
"self",
".",
"map",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"{self!r} is not bound to a Map\"",
")",
"return",
"(",
"not",
"bool",
"(",
"self",
".",... | A Key to sort the rules by weight for building.
The key leads to ordering:
- By routes with defaults first, as these must be evaulated
for building before ones without.
- Then the more complex routes (most converted parts). | [
"A",
"Key",
"to",
"sort",
"the",
"rules",
"by",
"weight",
"for",
"building",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L451-L462 |
231,790 | pgjones/quart | examples/http2_push/http2_push.py | get_tile | def get_tile(tile_number):
"""
Returns a crop of `img` based on a sequence number `tile_number`.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises TileOutOfBoundsError: When `tile_number` exceeds `max_tiles`^2
:rtype PIL.Image:
"""
tile_number = int(tile_number... | python | def get_tile(tile_number):
"""
Returns a crop of `img` based on a sequence number `tile_number`.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises TileOutOfBoundsError: When `tile_number` exceeds `max_tiles`^2
:rtype PIL.Image:
"""
tile_number = int(tile_number... | [
"def",
"get_tile",
"(",
"tile_number",
")",
":",
"tile_number",
"=",
"int",
"(",
"tile_number",
")",
"max_tiles",
"=",
"app",
".",
"max_tiles",
"if",
"tile_number",
">",
"max_tiles",
"*",
"max_tiles",
":",
"raise",
"TileOutOfBoundsError",
"(",
"'Requested an out... | Returns a crop of `img` based on a sequence number `tile_number`.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises TileOutOfBoundsError: When `tile_number` exceeds `max_tiles`^2
:rtype PIL.Image: | [
"Returns",
"a",
"crop",
"of",
"img",
"based",
"on",
"a",
"sequence",
"number",
"tile_number",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/examples/http2_push/http2_push.py#L21-L44 |
231,791 | pgjones/quart | examples/http2_push/http2_push.py | tile | async def tile(tile_number):
"""
Handles GET requests for a tile number.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises HTTPError: 404 if tile exceeds `max_tiles`^2.
"""
try:
tile = get_tile(tile_number)
except TileOutOfBoundsError:
abort(404... | python | async def tile(tile_number):
"""
Handles GET requests for a tile number.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises HTTPError: 404 if tile exceeds `max_tiles`^2.
"""
try:
tile = get_tile(tile_number)
except TileOutOfBoundsError:
abort(404... | [
"async",
"def",
"tile",
"(",
"tile_number",
")",
":",
"try",
":",
"tile",
"=",
"get_tile",
"(",
"tile_number",
")",
"except",
"TileOutOfBoundsError",
":",
"abort",
"(",
"404",
")",
"buf",
"=",
"BytesIO",
"(",
"tile",
".",
"tobytes",
"(",
")",
")",
"til... | Handles GET requests for a tile number.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises HTTPError: 404 if tile exceeds `max_tiles`^2. | [
"Handles",
"GET",
"requests",
"for",
"a",
"tile",
"number",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/examples/http2_push/http2_push.py#L66-L86 |
231,792 | pgjones/quart | quart/wrappers/_base.py | JSONMixin.is_json | def is_json(self) -> bool:
"""Returns True if the content_type is json like."""
content_type = self.mimetype
if content_type == 'application/json' or (
content_type.startswith('application/') and content_type.endswith('+json')
):
return True
else:
... | python | def is_json(self) -> bool:
"""Returns True if the content_type is json like."""
content_type = self.mimetype
if content_type == 'application/json' or (
content_type.startswith('application/') and content_type.endswith('+json')
):
return True
else:
... | [
"def",
"is_json",
"(",
"self",
")",
"->",
"bool",
":",
"content_type",
"=",
"self",
".",
"mimetype",
"if",
"content_type",
"==",
"'application/json'",
"or",
"(",
"content_type",
".",
"startswith",
"(",
"'application/'",
")",
"and",
"content_type",
".",
"endswi... | Returns True if the content_type is json like. | [
"Returns",
"True",
"if",
"the",
"content_type",
"is",
"json",
"like",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L40-L48 |
231,793 | pgjones/quart | quart/wrappers/_base.py | JSONMixin.get_json | async def get_json(
self, force: bool=False, silent: bool=False, cache: bool=True,
) -> Any:
"""Parses the body data as JSON and returns it.
Arguments:
force: Force JSON parsing even if the mimetype is not JSON.
silent: Do not trigger error handling if parsing fails,... | python | async def get_json(
self, force: bool=False, silent: bool=False, cache: bool=True,
) -> Any:
"""Parses the body data as JSON and returns it.
Arguments:
force: Force JSON parsing even if the mimetype is not JSON.
silent: Do not trigger error handling if parsing fails,... | [
"async",
"def",
"get_json",
"(",
"self",
",",
"force",
":",
"bool",
"=",
"False",
",",
"silent",
":",
"bool",
"=",
"False",
",",
"cache",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Any",
":",
"if",
"cache",
"and",
"self",
".",
"_cached_json",
"is",... | Parses the body data as JSON and returns it.
Arguments:
force: Force JSON parsing even if the mimetype is not JSON.
silent: Do not trigger error handling if parsing fails, without
this the :meth:`on_json_loading_failed` will be called on
error.
... | [
"Parses",
"the",
"body",
"data",
"as",
"JSON",
"and",
"returns",
"it",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L54-L82 |
231,794 | pgjones/quart | quart/wrappers/_base.py | _BaseRequestResponse.mimetype | def mimetype(self, value: str) -> None:
"""Set the mimetype to the value."""
if (
value.startswith('text/') or value == 'application/xml' or
(value.startswith('application/') and value.endswith('+xml'))
):
mimetype = f"{value}; charset={self.charset}"
... | python | def mimetype(self, value: str) -> None:
"""Set the mimetype to the value."""
if (
value.startswith('text/') or value == 'application/xml' or
(value.startswith('application/') and value.endswith('+xml'))
):
mimetype = f"{value}; charset={self.charset}"
... | [
"def",
"mimetype",
"(",
"self",
",",
"value",
":",
"str",
")",
"->",
"None",
":",
"if",
"(",
"value",
".",
"startswith",
"(",
"'text/'",
")",
"or",
"value",
"==",
"'application/xml'",
"or",
"(",
"value",
".",
"startswith",
"(",
"'application/'",
")",
"... | Set the mimetype to the value. | [
"Set",
"the",
"mimetype",
"to",
"the",
"value",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L117-L126 |
231,795 | pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.blueprint | def blueprint(self) -> Optional[str]:
"""Returns the blueprint the matched endpoint belongs to.
This can be None if the request has not been matched or the
endpoint is not in a blueprint.
"""
if self.endpoint is not None and '.' in self.endpoint:
return self.endpoint... | python | def blueprint(self) -> Optional[str]:
"""Returns the blueprint the matched endpoint belongs to.
This can be None if the request has not been matched or the
endpoint is not in a blueprint.
"""
if self.endpoint is not None and '.' in self.endpoint:
return self.endpoint... | [
"def",
"blueprint",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"endpoint",
"is",
"not",
"None",
"and",
"'.'",
"in",
"self",
".",
"endpoint",
":",
"return",
"self",
".",
"endpoint",
".",
"rsplit",
"(",
"'.'",
",",
"... | Returns the blueprint the matched endpoint belongs to.
This can be None if the request has not been matched or the
endpoint is not in a blueprint. | [
"Returns",
"the",
"blueprint",
"the",
"matched",
"endpoint",
"belongs",
"to",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L195-L204 |
231,796 | pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.base_url | def base_url(self) -> str:
"""Returns the base url without query string or fragments."""
return urlunparse(ParseResult(self.scheme, self.host, self.path, '', '', '')) | python | def base_url(self) -> str:
"""Returns the base url without query string or fragments."""
return urlunparse(ParseResult(self.scheme, self.host, self.path, '', '', '')) | [
"def",
"base_url",
"(",
"self",
")",
"->",
"str",
":",
"return",
"urlunparse",
"(",
"ParseResult",
"(",
"self",
".",
"scheme",
",",
"self",
".",
"host",
",",
"self",
".",
"path",
",",
"''",
",",
"''",
",",
"''",
")",
")"
] | Returns the base url without query string or fragments. | [
"Returns",
"the",
"base",
"url",
"without",
"query",
"string",
"or",
"fragments",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L266-L268 |
231,797 | pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.url | def url(self) -> str:
"""Returns the full url requested."""
return urlunparse(
ParseResult(
self.scheme, self.host, self.path, '', self.query_string.decode('ascii'), '',
),
) | python | def url(self) -> str:
"""Returns the full url requested."""
return urlunparse(
ParseResult(
self.scheme, self.host, self.path, '', self.query_string.decode('ascii'), '',
),
) | [
"def",
"url",
"(",
"self",
")",
"->",
"str",
":",
"return",
"urlunparse",
"(",
"ParseResult",
"(",
"self",
".",
"scheme",
",",
"self",
".",
"host",
",",
"self",
".",
"path",
",",
"''",
",",
"self",
".",
"query_string",
".",
"decode",
"(",
"'ascii'",
... | Returns the full url requested. | [
"Returns",
"the",
"full",
"url",
"requested",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L286-L292 |
231,798 | pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.cookies | def cookies(self) -> Dict[str, str]:
"""The parsed cookies attached to this request."""
cookies = SimpleCookie()
cookies.load(self.headers.get('Cookie', ''))
return {key: cookie.value for key, cookie in cookies.items()} | python | def cookies(self) -> Dict[str, str]:
"""The parsed cookies attached to this request."""
cookies = SimpleCookie()
cookies.load(self.headers.get('Cookie', ''))
return {key: cookie.value for key, cookie in cookies.items()} | [
"def",
"cookies",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"cookies",
"=",
"SimpleCookie",
"(",
")",
"cookies",
".",
"load",
"(",
"self",
".",
"headers",
".",
"get",
"(",
"'Cookie'",
",",
"''",
")",
")",
"return",
"{",
"k... | The parsed cookies attached to this request. | [
"The",
"parsed",
"cookies",
"attached",
"to",
"this",
"request",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L307-L311 |
231,799 | pgjones/quart | quart/config.py | Config.from_envvar | def from_envvar(self, variable_name: str, silent: bool=False) -> None:
"""Load the configuration from a location specified in the environment.
This will load a cfg file using :meth:`from_pyfile` from the
location specified in the environment, for example the two blocks
below are equival... | python | def from_envvar(self, variable_name: str, silent: bool=False) -> None:
"""Load the configuration from a location specified in the environment.
This will load a cfg file using :meth:`from_pyfile` from the
location specified in the environment, for example the two blocks
below are equival... | [
"def",
"from_envvar",
"(",
"self",
",",
"variable_name",
":",
"str",
",",
"silent",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"value",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"variable_name",
")",
"if",
"value",
"is",
"None",
"and",
"not... | Load the configuration from a location specified in the environment.
This will load a cfg file using :meth:`from_pyfile` from the
location specified in the environment, for example the two blocks
below are equivalent.
.. code-block:: python
app.config.from_envvar('CONFIG')... | [
"Load",
"the",
"configuration",
"from",
"a",
"location",
"specified",
"in",
"the",
"environment",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L88-L109 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.