Schedule a task to run later, after the loop has started.
Different from asyncio.ensure_future in that it does not
also return a future, and the actual ensure_future call
is delayed until before server start.

Register an application level middleware that will be attached
to all the API URLs registered under this application.

This method is internally invoked by the middleware()
decorator provided at the app level.

Parameters

middleware – Callback method to be attached to the
middleware

attach_to – The state at which the middleware needs to be
invoked in the lifecycle of an HTTP Request.
request - Invoke before the request is processed
response - Invoke before the response is returned back

Register a root to serve files from. The input can either be a
file or a directory. This method will enable an easy and simple way
to setup the Route necessary to serve the static files.

Parameters

uri – URL path to be used for serving static content

file_or_directory – Path for the Static file/directory with
static files

pattern – Regex Pattern identifying the valid static files

use_modified_since – If true, send file modified time, and return
not modified if the browser’s matches the server’s

use_content_range – If true, process header for range requests
and sends the file part that is requested

stream_large_files – If true, use the
StreamingHTTPResponse.file_stream() handler rather
than the HTTPResponse.file() handler to send the file.
If this is an integer, this represents the threshold size to
switch to StreamingHTTPResponse.file_stream()

name – user defined name used for url_for

host – Host IP or FQDN for the service to use

strict_slashes – Instruct Sanic to check if the request
URLs need to terminate with a /

In order to build a URL, all request parameters must be supplied as
keyword arguments, and each parameter must pass the test for the
specified parameter type. If these conditions are not met, a
URLBuildError will be thrown.

Keyword arguments that are not request parameters will be included in
the output URL’s query string.

Parameters

view_name – string referencing the view name

**kwargs – keys and values that are used to build request
parameters and query string arguments.

This class provides a mechanism to implement a Blueprint Group
using the group() method in
Blueprint. To avoid having to re-write
some of the existing implementation, this class provides a custom
iterator implementation that will let you use the object of this
class as a list/tuple inside the existing implementation.

You should not use this function to load the actual configuration but
rather configuration defaults. The actual config should be loaded
with from_pyfile() and ideally from a location not within the
package because the package might be installed system wide.

CookieJar dynamically writes headers as cookies are added and removed
It gets around the limitation of one header per name by using the
MultiHeader class to provide a unique key that encodes to Set-Cookie.

The Web server (running the Web site) thinks that there has been too
long an interval of time between 1) the establishment of an IP
connection (socket) between the client and the server and
2) the receipt of any data on that socket, so the server has dropped
the connection. The socket connection has actually been lost - the Web
server has ‘timed out’ on that particular socket connection.

When present, kwargs is used to complete the WWW-Authentication header.

Examples:

# With a Basic auth-scheme, realm MUST be present:raiseUnauthorized("Auth required.",scheme="Basic",realm="Restricted Area")# With a Digest auth-scheme, things are a bit more complicated:raiseUnauthorized("Auth required.",scheme="Digest",realm="Restricted Area",qop="auth, auth-int",algorithm="MD5",nonce="abcdef",opaque="zyxwvu")# With a Bearer auth-scheme, realm is optional so you can write:raiseUnauthorized("Auth required.",scheme="Bearer")# or, if you want to specify the realm:raiseUnauthorized("Auth required.",scheme="Bearer",realm="Restricted Area")

Provide sanic.app.Sanic application with a mechanism to handle
and process any and all uncaught exceptions in a way the application
developer will set fit.

This error handling framework is built into the core that can be extended
by the developers to perform a wide range of tasks from recording the error
stats to reporting them to an external service that can be used for
realtime alerting system.

Method to parse query_string using urllib.parse.parse_qs.
This methods is used by args property.
Can be used directly if you need to change default parameters.

Parameters

keep_blank_values (bool) – flag indicating whether blank values in
percent-encoded queries should be treated as blank strings.
A true value indicates that blanks should be retained as blank
strings. The default false value indicates that blank values
are to be ignored and treated as if they were not included.

strict_parsing (bool) – flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored. If true,
errors raise a ValueError exception.

encoding (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

errors (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

Method to parse query_string using urllib.parse.parse_qs.
This methods is used by args property.
Can be used directly if you need to change default parameters.

Parameters

keep_blank_values (bool) – flag indicating whether blank values in
percent-encoded queries should be treated as blank strings.
A true value indicates that blanks should be retained as blank
strings. The default false value indicates that blank values
are to be ignored and treated as if they were not included.

strict_parsing (bool) – flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored. If true,
errors raise a ValueError exception.

encoding (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

errors (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

Method to parse query_string using urllib.parse.parse_qsl.
This methods is used by query_args property.
Can be used directly if you need to change default parameters.

Parameters

keep_blank_values (bool) – flag indicating whether blank values in
percent-encoded queries should be treated as blank strings.
A true value indicates that blanks should be retained as blank
strings. The default false value indicates that blank values
are to be ignored and treated as if they were not included.

strict_parsing (bool) – flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored. If true,
errors raise a ValueError exception.

encoding (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

errors (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

Method to parse query_string using urllib.parse.parse_qsl.
This methods is used by query_args property.
Can be used directly if you need to change default parameters.

Parameters

keep_blank_values (bool) – flag indicating whether blank values in
percent-encoded queries should be treated as blank strings.
A true value indicates that blanks should be retained as blank
strings. The default false value indicates that blank values
are to be ignored and treated as if they were not included.

strict_parsing (bool) – flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored. If true,
errors raise a ValueError exception.

encoding (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

errors (str) – specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.

Attempt to get the server’s external port number in this order:
config.SERVER_NAME, proxied or direct Host headers
Request.host(),
actual port used by the transport layer socket.
:return: server port
:rtype: int

Parameters will be passed as keyword arguments to the request handling
function. Provided parameters can also have a type by appending :type to
the <parameter>. Given parameter must be able to be type-casted to this.
If no type is provided, a string is expected. A regular expression can
also be passed in as the type. The argument given to the function will
always be a string, independent of the type.

Pause and resume calls are paired – pause_writing() is called
once when the buffer goes strictly over the high-water mark
(even if subsequent writes increases the buffer size even
more), and eventually resume_writing() is called once when the
buffer size reaches the low-water mark.

Note that if the buffer size equals the high-water mark,
pause_writing() is not called – it must go strictly over.
Conversely, resume_writing() is called when the buffer size is
equal or lower than the low-water mark. These end conditions
are important to ensure that things go as expected when either
mark is zero.

NOTE: This is the only Protocol callback that is not called
through EventLoop.call_soon() – if it were, it would have no
effect when it’s most needed (when the app keeps writing
without yielding until pause_writing() is called).

Schedule a task to run later, after the loop has started.
Different from asyncio.ensure_future in that it does not
also return a future, and the actual ensure_future call
is delayed until before server start.

Register an application level middleware that will be attached
to all the API URLs registered under this application.

This method is internally invoked by the middleware()
decorator provided at the app level.

Parameters

middleware – Callback method to be attached to the
middleware

attach_to – The state at which the middleware needs to be
invoked in the lifecycle of an HTTP Request.
request - Invoke before the request is processed
response - Invoke before the response is returned back

Register a root to serve files from. The input can either be a
file or a directory. This method will enable an easy and simple way
to setup the Route necessary to serve the static files.

Parameters

uri – URL path to be used for serving static content

file_or_directory – Path for the Static file/directory with
static files

pattern – Regex Pattern identifying the valid static files

use_modified_since – If true, send file modified time, and return
not modified if the browser’s matches the server’s

use_content_range – If true, process header for range requests
and sends the file part that is requested

stream_large_files – If true, use the
StreamingHTTPResponse.file_stream() handler rather
than the HTTPResponse.file() handler to send the file.
If this is an integer, this represents the threshold size to
switch to StreamingHTTPResponse.file_stream()

name – user defined name used for url_for

host – Host IP or FQDN for the service to use

strict_slashes – Instruct Sanic to check if the request
URLs need to terminate with a /

In order to build a URL, all request parameters must be supplied as
keyword arguments, and each parameter must pass the test for the
specified parameter type. If these conditions are not met, a
URLBuildError will be thrown.

Keyword arguments that are not request parameters will be included in
the output URL’s query string.

Parameters

view_name – string referencing the view name

**kwargs – keys and values that are used to build request
parameters and query string arguments.