-
class
flask.
Request
(environ, populate_request=True, shallow=False)[source] The request object used by default in Flask. Remembers the matched endpoint and view arguments.
It is what ends up as
request
. If you want to replace the request object used you can subclass this and setrequest_class
to your subclass.The request object is a
Request
subclass and provides all of the attributes Werkzeug defines plus a few Flask specific ones.
Methods
__init__ (environ[, populate_request, shallow]) |
|
application (f) |
Decorate a function as responder that accepts the request as first argument. |
close () |
Closes associated resources of this request object. |
from_values (*args, **kwargs) |
Create a new request object based on the values provided. |
get_data ([cache, as_text, parse_form_data]) |
This reads the buffered incoming data from the client into one bytestring. |
get_json ([force, silent, cache]) |
Parses the incoming JSON request data and returns it. |
make_form_data_parser () |
Creates the form data parser. |
on_json_loading_failed (e) |
Called if decoding of the JSON data failed. |
Attributes
accept_charsets |
List of charsets this client supports as CharsetAccept object. |
accept_encodings |
List of encodings this client accepts. |
accept_languages |
List of languages this client accepts as LanguageAccept object. |
accept_mimetypes |
List of mimetypes this client supports as MIMEAccept object. |
access_route |
If a forwarded header exists this is a list of all ip addresses from the client ip to the last proxy server. |
args |
The parsed URL parameters. |
authorization |
The Authorization object in parsed form. |
base_url |
Like url but without the querystring See also: trusted_hosts . |
blueprint |
The name of the current blueprint |
cache_control |
A RequestCacheControl object for the incoming cache control headers. |
charset |
|
content_encoding |
The Content-Encoding entity-header field is used as a modifier to the media-type. |
content_length |
The Content-Length entity-header field indicates the size of the entity-body in bytes or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET. |
content_md5 |
The Content-MD5 entity-header field, as defined in RFC 1864, is an MD5 digest of the entity-body for the purpose of providing an end-to-end message integrity check (MIC) of the entity-body. |
content_type |
The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET. |
cookies |
Read only access to the retrieved cookie values as dictionary. |
data |
|
date |
The Date general-header field represents the date and time at which the message was originated, having the same semantics as orig-date in RFC 822. |
disable_data_descriptor |
|
encoding_errors |
|
endpoint |
The endpoint that matched the request. |
files |
MultiDict object containing |
form |
The form parameters. |
full_path |
Requested path as unicode, including the query string. |
headers |
The headers from the WSGI environ as immutable EnvironHeaders . |
host |
Just the host including the port if available. |
host_url |
Just the host with scheme as IRI. |
if_match |
An object containing all the etags in the If-Match header. |
if_modified_since |
The parsed If-Modified-Since header as datetime object. |
if_none_match |
An object containing all the etags in the If-None-Match header. |
if_range |
The parsed If-Range header. |
if_unmodified_since |
The parsed If-Unmodified-Since header as datetime object. |
input_stream |
|
is_json |
Indicates if this request is JSON or not. |
is_multiprocess |
boolean that is True if the application is served by |
is_multithread |
boolean that is True if the application is served by |
is_run_once |
boolean that is True if the application will be executed only |
is_secure |
True if the request is secure. |
is_xhr |
True if the request was triggered via a JavaScript XMLHttpRequest. |
json |
If the mimetype is application/json this will contain the parsed JSON data. |
max_content_length |
Read-only view of the MAX_CONTENT_LENGTH config key. |
max_form_memory_size |
|
max_forwards |
The Max-Forwards request-header field provides a mechanism with the TRACE and OPTIONS methods to limit the number of proxies or gateways that can forward the request to the next inbound server. |
method |
The transmission method. |
mimetype |
Like content_type , but without parameters (eg, without charset, type etc.) and always lowercase. |
mimetype_params |
The mimetype parameters as dict. |
module |
The name of the current module if the request was dispatched to an actual module. |
path |
Requested path as unicode. |
pragma |
The Pragma general-header field is used to include implementation-specific directives that might apply to any recipient along the request/response chain. |
query_string |
The URL parameters as raw bytestring. |
range |
The parsed Range header. |
referrer |
The Referer[sic] request-header field allows the client to specify, for the server’s benefit, the address (URI) of the resource from which the Request-URI was obtained (the “referrer”, although the header field is misspelled). |
remote_addr |
The remote address of the client. |
remote_user |
If the server supports user authentication, and the script is protected, this attribute contains the username the user has authenticated as. |
routing_exception |
If matching the URL failed, this is the exception that will be raised / was raised as part of the request handling. |
scheme |
URL scheme (http or https). |
script_root |
The root path of the script without the trailing slash. |
stream |
The stream to read incoming data from. |
trusted_hosts |
|
url |
The reconstructed current URL as IRI. |
url_charset |
The charset that is assumed for URLs. |
url_root |
The full URL root (with hostname), this is the application root as IRI. |
url_rule |
The internal URL rule that matched the request. |
user_agent |
The current user agent. |
values |
Combined multi dict for args and form . |
view_args |
A dict of view arguments that matched the request. |
want_form_data_parsed |
Returns True if the request method carries content. |