werkzeug API reference
179 public APIs from werkzeug (pallets/werkzeug) — 53 classes, 30 functions, 96 methods. Signatures extracted by static analysis of the actual source.
Repository: pallets/werkzeug
| Kind | Count |
|---|---|
| Classes | 53 |
| Functions | 30 |
| Methods | 96 |
API list
func
src.werkzeug._reloader.ensure_echo_on() -> NoneEnsure that echo mode is enabled.
method
src.werkzeug.datastructures.auth.Authorization.to_header() -> strConvert to an ``Authorization`` header value.
class
src.werkzeug.datastructures.cache_control.RequestCacheControlA cache control for requests.
class
src.werkzeug.datastructures.cache_control.ResponseCacheControlA cache control for responses.
func
src.werkzeug.datastructures.csp.csp_property(key:str, deprecated:str | None=None) -> t.AnyCreate a property for a CSP directive.
method
src.werkzeug.datastructures.file_storage.FileMultiDict.add_file(name:str, file:str | os.PathLike[str] | t.IO[bytes] | FileStorage, filename:str | None=None, content_type:str | None=None) -> NoneAdd a file to the given key.
method
src.werkzeug.datastructures.file_storage.FileMultiDict.clear() -> NoneCall :meth:`close`, then remove all items.
method
src.werkzeug.datastructures.file_storage.FileStorage.close() -> NoneClose the underlying file if possible.
method
src.werkzeug.datastructures.file_storage.FileStorage.content_length() -> intThe content-length sent in the header.
method
src.werkzeug.datastructures.file_storage.FileStorage.content_type() -> str | NoneThe content-type sent in the header.
method
src.werkzeug.datastructures.file_storage.FileStorage.mimetype_params() -> dict[str, str]The mimetype parameters as dict.
class
src.werkzeug.datastructures.headers.HeadersAn object that stores some headers.
method
src.werkzeug.datastructures.headers.Headers.add(key:str, value:t.Any, **kwargs:t.Any) -> NoneAdd a new header tuple to the list.
method
src.werkzeug.datastructures.headers.Headers.add_header(key:str, value:t.Any, **kwargs:t.Any) -> NoneAdd a new header tuple to the list.
method
src.werkzeug.datastructures.headers.Headers.clear() -> NoneClears all headers.
method
src.werkzeug.datastructures.headers.Headers.get_all(name:str) -> list[str]Return a list of all the values for the named field.
method
src.werkzeug.datastructures.headers.Headers.remove(key:str) -> NoneRemove a key.
method
src.werkzeug.datastructures.headers.Headers.set(key:str, value:t.Any, **kwargs:t.Any) -> NoneRemove all header tuples for `key` and add a new one.
method
src.werkzeug.datastructures.headers.Headers.setlist(key:str, values:cabc.Iterable[t.Any]) -> NoneRemove any existing values for a header and add new ones.
class
src.werkzeug.datastructures.mixins.ImmutableDictMixinMakes a :class:`dict` immutable.
class
src.werkzeug.datastructures.mixins.ImmutableHeadersMixinMakes a :class:`Headers` immutable.
class
src.werkzeug.datastructures.mixins.ImmutableListMixinMakes a :class:`list` immutable.
class
src.werkzeug.datastructures.mixins.ImmutableMultiDictMixinMakes a :class:`MultiDict` immutable.
class
src.werkzeug.datastructures.mixins.UpdateDictMixinMakes dicts call `self.on_update` on modifications.
class
src.werkzeug.datastructures.range.ContentRangeRepresents the content range header.
method
src.werkzeug.datastructures.range.ContentRange.set(start:int | None, stop:int | None, length:int | None=None, units:str | None='bytes') -> NoneSimple method to update the ranges.
method
src.werkzeug.datastructures.range.ContentRange.to_header() -> strConvert to a ``Content-Range`` header value.
class
src.werkzeug.datastructures.range.IfRangeA parsed ``If-Range`` header.
method
src.werkzeug.datastructures.range.IfRange.to_header() -> strConvert to an ``If-Range`` header value.
class
src.werkzeug.datastructures.range.RangeRepresents a ``Range`` header.
method
src.werkzeug.datastructures.range.Range.to_header() -> strConvert to a ``Range`` header value.
class
src.werkzeug.datastructures.structures.ImmutableDictAn immutable :class:`dict`.
method
src.werkzeug.datastructures.structures.ImmutableDict.copy() -> dict[K, V]Return a shallow mutable copy of this object.
class
src.werkzeug.datastructures.structures.ImmutableListAn immutable :class:`list`.
class
src.werkzeug.datastructures.structures.ImmutableMultiDictAn immutable :class:`MultiDict`.
method
src.werkzeug.datastructures.structures.ImmutableMultiDict.copy() -> MultiDict[K, V]Return a shallow mutable copy of this object.
method
src.werkzeug.datastructures.structures.MultiDict.add(key:K, value:V) -> NoneAdds a new value for the key.
method
src.werkzeug.datastructures.structures.MultiDict.copy() -> te.SelfReturn a shallow copy of this object.
method
src.werkzeug.datastructures.structures.MultiDict.deepcopy(memo:t.Any=None) -> te.SelfReturn a deep copy of this object.
method
src.werkzeug.datastructures.structures.MultiDict.items(multi:bool=False) -> cabc.Iterable[tuple[K, V]]Return an iterator of ``(key, value)`` pairs.
method
src.werkzeug.datastructures.structures.MultiDict.popitem() -> tuple[K, V]Pop an item from the dict.
method
src.werkzeug.datastructures.structures.MultiDict.popitemlist() -> tuple[K, list[V]]Pop a ``(key, list)`` tuple from the dict.
method
src.werkzeug.datastructures.structures.MultiDict.poplist(key:K) -> list[V]Pop the list for a key from the dict.
method
src.werkzeug.datastructures.structures.MultiDict.setlist(key:K, new_list:cabc.Iterable[V]) -> NoneRemove the old values for a key and add new ones.
method
src.werkzeug.datastructures.structures.MultiDict.setlistdefault(key:K, default_list:cabc.Iterable[V] | None=None) -> list[V]Like `setdefault` but sets multiple values.
class
src.werkzeug.debug.console.ConsoleAn interactive console.
class
src.werkzeug.debug.console.HTMLStringOA StringO version that HTML escapes on write.
func
src.werkzeug.debug.repr.debug_repr(obj:object) -> strCreates a debug repr of an object as HTML string.
class
src.werkzeug.exceptions.BadHostRaised if the submitted host is badly formatted.
class
src.werkzeug.exceptions.HTTPExceptionThe base class for all HTTP exceptions.
method
src.werkzeug.exceptions.HTTPException.get_body(environ:WSGIEnvironment | None=None, scope:dict[str, t.Any] | None=None) -> strGet the HTML body.
method
src.werkzeug.exceptions.HTTPException.get_description(environ:WSGIEnvironment | None=None, scope:dict[str, t.Any] | None=None) -> strGet the description.
method
src.werkzeug.exceptions.HTTPException.get_headers(environ:WSGIEnvironment | None=None, scope:dict[str, t.Any] | None=None) -> list[tuple[str, str]]Get a list of headers.
method
src.werkzeug.exceptions.HTTPException.name() -> strThe status name.
class
src.werkzeug.exceptions.RequestTimeout*408* `Request Timeout` Raise to signalize a timeout.
class
src.werkzeug.exceptions.SecurityErrorRaised if something triggers a security error.
class
src.werkzeug.formparser.FormDataParserThis class implements parsing of form data for Werkzeug.
class
src.werkzeug.http.COEP``Cross-Origin-Embedder-Policy`` header values.
class
src.werkzeug.http.COOP``Cross-Origin-Opener-Policy`` header values.
class
src.werkzeug.http.CORP``Cross-Origin-Resource-Policy`` header values.
class
src.werkzeug.http.SecFetchDest``Sec-Fetch-Dest`` header values.
class
src.werkzeug.http.SecFetchMode``Sec-Fetch-Mode`` header values.
class
src.werkzeug.http.SecFetchSite``Sec-Fetch-Site`` header values.
func
src.werkzeug.http.dump_age(age:timedelta | int | None=None) -> str | NoneFormats the duration as a base-10 integer.
func
src.werkzeug.http.generate_etag(data:bytes) -> strGenerate a strong ETag value by hashing the given data.
func
src.werkzeug.http.is_entity_header(header:str) -> boolCheck if a header is an entity header.
func
src.werkzeug.http.is_hop_by_hop_header(header:str) -> boolCheck if a header is an HTTP/1.1 "Hop-by-Hop" header.
func
src.werkzeug.http.parse_age(value:str | None=None) -> timedelta | NoneParses a base-10 integer count of seconds into a timedelta.
func
src.werkzeug.http.quote_etag(etag:str, weak:bool=False) -> strQuote an etag.
func
src.werkzeug.http.quote_header_value(value:t.Any, allow_token:bool=True) -> strAdd double quotes around a header value.
func
src.werkzeug.http.unquote_header_value(value:str) -> strRemove double quotes and backslash escapes from a header value.
class
src.werkzeug.local.LocalCreate a namespace of context-local data.
method
src.werkzeug.local.LocalManager.cleanup() -> NoneRelease the data in the locals for this context.
class
src.werkzeug.local.LocalProxyA proxy to the object bound to a context-local object.
class
src.werkzeug.local.LocalStackCreate a stack of context-local data.
method
src.werkzeug.local.LocalStack.pop() -> T | NoneRemove the top item from the stack and return it.
method
src.werkzeug.local.LocalStack.push(obj:T) -> list[T]Add a new item to the top of the stack.
method
src.werkzeug.local.LocalStack.top() -> T | NoneThe topmost item on the stack.
class
src.werkzeug.middleware.lint.HTTPWarningWarning class for HTTP warnings.
class
src.werkzeug.middleware.lint.WSGIWarningWarning class for WSGI warnings.
class
src.werkzeug.routing.converters.AnyConverterMatches one of the items provided.
class
src.werkzeug.routing.converters.BaseConverterBase class for all converters.
class
src.werkzeug.routing.converters.NumberConverterBaseclass for `IntegerConverter` and `FloatConverter`.
class
src.werkzeug.routing.converters.ValidationErrorValidation error.
class
src.werkzeug.routing.exceptions.RequestPathInternal exception.
class
src.werkzeug.routing.exceptions.RequestRedirectRaise if the map requests a redirect.
method
src.werkzeug.routing.map.Map.add(rulefactory:RuleFactory) -> NoneAdd a new rule or factory to the map and bind it.
method
src.werkzeug.routing.map.Map.iter_rules(endpoint:t.Any | None=None) -> t.Iterator[Rule]Iterate over all rules or the rules of an endpoint.
class
src.werkzeug.routing.matcher.StateA representation of a rule state.
class
src.werkzeug.routing.rules.RuleA Rule represents one URL pattern.
method
src.werkzeug.routing.rules.Rule.build_compare_key() -> tuple[int, int, int]The build compare key for sorting.
method
src.werkzeug.routing.rules.Rule.compile() -> NoneCompiles the regular expression and stores it.
method
src.werkzeug.routing.rules.Rule.empty() -> RuleReturn an unbound copy of this rule.
method
src.werkzeug.routing.rules.Rule.is_duplicate(other:Rule) -> boolCheck if this rule would match in the same way as another rule.
method
src.werkzeug.routing.rules.Rule.provides_defaults_for(rule:Rule) -> boolCheck if this rule has defaults for a given rule.
method
src.werkzeug.routing.rules.Rule.refresh() -> NoneRebinds and refreshes the URL.
class
src.werkzeug.routing.rules.RulePartA part of a rule.
class
src.werkzeug.routing.rules.RuleTemplateFactoryA factory that fills in template variables into rules.
class
src.werkzeug.sansio.multipart.MultipartDecoderDecodes a multipart message as bytes into Python events.
method
src.werkzeug.sansio.request.Request.base_url() -> strLike :attr:`url` but without the query string.
method
src.werkzeug.sansio.request.Request.full_path() -> strRequested path, including the query string.
method
src.werkzeug.sansio.request.Request.host_url() -> strThe request URL scheme and host only.
method
src.werkzeug.sansio.request.Request.if_match() -> ETagsETags parsed from the ``If-Match`` header.
method
src.werkzeug.sansio.request.Request.if_none_match() -> ETagsETags parsed from the ``If-None-Match`` header.
method
src.werkzeug.sansio.request.Request.if_range() -> IfRangeThe parsed ``If-Range`` header.
method
src.werkzeug.sansio.request.Request.mimetype_params() -> dict[str, str]The mimetype parameters as dict.
method
src.werkzeug.sansio.request.Request.pragma() -> HeaderSetThe ``Pragma`` header.
method
src.werkzeug.sansio.request.Request.range() -> Range | NoneThe parsed `Range` header.
method
src.werkzeug.sansio.request.Request.root_url() -> strThe request URL scheme, host, and root path.
method
src.werkzeug.sansio.request.Request.user_agent() -> UserAgentThe user agent.
method
src.werkzeug.sansio.response.Response.delete_cookie(key:str, path:str | None='/', domain:str | None=None, secure:bool=False, httponly:bool=False, samesite:str | None=None, partitioned:bool=False) -> NoneDelete a cookie.
method
src.werkzeug.sansio.response.Response.mimetype() -> str | NoneThe mimetype (content type without charset etc.)
method
src.werkzeug.sansio.response.Response.mimetype_params() -> dict[str, str]The mimetype parameters as dict.
method
src.werkzeug.sansio.response.Response.set_cookie(key:str, value:str='', max_age:timedelta | int | None=None, expires:str | datetime | int | float | None=None, path:str | None='/', domain:str | None=None, secure:bool=False, httponly:bool=False, samesite:str | None=None, partitioned:bool=False) -> NoneSets a cookie.
method
src.werkzeug.sansio.response.Response.set_etag(etag:str, weak:bool=False) -> NoneSet the etag, and override the old one if there was one.
method
src.werkzeug.sansio.response.Response.status() -> strThe HTTP status code as a string.
method
src.werkzeug.sansio.response.Response.status_code() -> intThe HTTP status code as a number.
func
src.werkzeug.sansio.utils.get_content_length(http_content_length:str | None=None, http_transfer_encoding:str | None=None) -> int | NoneReturn the ``Content-Length`` header value as an int.
func
src.werkzeug.sansio.utils.get_current_url(scheme:str, host:str, root_path:str | None=None, path:str | None=None, query_string:bytes | None=None) -> strRecreate the URL for a request.
func
src.werkzeug.sansio.utils.host_is_trusted(hostname:str | None, trusted_list:t.Collection[str] | None=None) -> boolPerform some checks on a ``Host`` header ``host:port``.
func
src.werkzeug.security.generate_password_hash(password:str, method:str='scrypt', salt_length:int=16) -> strSecurely hash a password for storage.
class
src.werkzeug.serving.BaseWSGIServerA WSGI server that that handles one request at a time.
class
src.werkzeug.serving.DechunkedInputAn input stream that handles Transfer-Encoding 'chunked'
class
src.werkzeug.serving.WSGIRequestHandlerA request handler that implements WSGI dispatching.
method
src.werkzeug.serving.WSGIRequestHandler.connection_dropped(error:BaseException, environ:WSGIEnvironment | None=None) -> NoneCalled if the connection was closed by the client.
method
src.werkzeug.serving.WSGIRequestHandler.handle() -> NoneHandles a request ignoring dropped connections.
func
src.werkzeug.serving.get_interface_ip(family:socket.AddressFamily) -> strGet the IP address of an external interface.
func
src.werkzeug.serving.is_ssl_error(error:Exception | None=None) -> boolChecks if the given error (or the current one) is an SSL error.
func
src.werkzeug.serving.make_ssl_devcert(base_path:str, host:str | None=None, cn:str | None=None) -> tuple[str, str]Creates an SSL key for development.
method
src.werkzeug.test.Client.delete(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``DELETE``.
method
src.werkzeug.test.Client.delete_cookie(key:str, *domain:str='localhost', *path:str='/') -> NoneDelete a cookie if it exists.
method
src.werkzeug.test.Client.get(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``GET``.
method
src.werkzeug.test.Client.get_cookie(key:str, domain:str='localhost', path:str='/') -> Cookie | NoneReturn a :class:`.Cookie` if it exists.
method
src.werkzeug.test.Client.head(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``HEAD``.
method
src.werkzeug.test.Client.options(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``OPTIONS``.
method
src.werkzeug.test.Client.patch(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``PATCH``.
method
src.werkzeug.test.Client.post(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``POST``.
method
src.werkzeug.test.Client.put(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``PUT``.
method
src.werkzeug.test.Client.query(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``QUERY``.
method
src.werkzeug.test.Client.set_cookie(key:str, value:str='', *domain:str='localhost', *origin_only:bool=True, *path:str='/', **kwargs:t.Any) -> NoneSet a cookie to be sent in subsequent requests.
method
src.werkzeug.test.Client.trace(*args:t.Any, **kw:t.Any) -> TestResponseCall :meth:`open` with ``method`` set to ``TRACE``.
class
src.werkzeug.test.CookieA cookie key, value, and parameters.
func
src.werkzeug.test.create_environ(*args:t.Any, **kwargs:t.Any) -> WSGIEnvironmentCreate a new WSGI environ dict based on the values passed.
func
src.werkzeug.urls.iri_to_uri(iri:str) -> strConvert an IRI to a URI.
func
src.werkzeug.urls.uri_to_iri(uri:str) -> strConvert a URI to an IRI.
class
src.werkzeug.user_agent.UserAgentRepresents a parsed user agent header value.
method
src.werkzeug.user_agent.UserAgent.to_header() -> strConvert to a header value.
class
src.werkzeug.utils.ImportStringErrorProvides information about a failed :func:`import_string` attempt.
func
src.werkzeug.utils.append_slash_redirect(environ:WSGIEnvironment, code:int=308) -> ResponseRedirect to the current URL with a slash appended.
class
src.werkzeug.utils.cached_propertyA :func:`property` that is only evaluated once.
class
src.werkzeug.utils.environ_propertyMaps request attributes to environment variables.
func
src.werkzeug.utils.find_modules(import_path:str, include_packages:bool=False, recursive:bool=False) -> t.Iterator[str]Finds all the modules below a package.
func
src.werkzeug.utils.get_content_type(mimetype:str, charset:str) -> strReturns the full content type string with charset for a mimetype.
class
src.werkzeug.utils.header_propertyLike `environ_property` but for headers.
func
src.werkzeug.utils.import_string(import_name:str, silent:bool=False) -> t.AnyImports an object based on a string.
func
src.werkzeug.utils.secure_filename(filename:str) -> strPass it a filename and it will return a secure version of it.
method
src.werkzeug.wrappers.request.Request.close() -> NoneCloses associated resources of this request object.
method
src.werkzeug.wrappers.request.Request.data() -> bytesThe raw data read from :attr:`stream`.
method
src.werkzeug.wrappers.request.Request.from_values(*args:t.Any, **kwargs:t.Any) -> te.SelfCreate a new request object based on the values provided.
method
src.werkzeug.wrappers.request.Request.make_form_data_parser() -> FormDataParserCreates the form data parser.
method
src.werkzeug.wrappers.request.Request.on_json_loading_failed(e:ValueError | None) -> t.AnyCalled if :meth:`get_json` fails and isn't silenced.
method
src.werkzeug.wrappers.request.Request.script_root() -> strAlias for :attr:`self.root_path`.
method
src.werkzeug.wrappers.request.Request.stream() -> t.IO[bytes]The WSGI input stream, with safety checks.
method
src.werkzeug.wrappers.request.Request.url_root() -> strAlias for :attr:`root_url`.
method
src.werkzeug.wrappers.request.Request.want_form_data_parsed() -> bool``True`` if the request method carries content.
method
src.werkzeug.wrappers.response.Response.add_etag(overwrite:bool=False, weak:bool=False) -> NoneAdd an ETag by hashing this response's data.
method
src.werkzeug.wrappers.response.Response.close() -> NoneClose the wrapped response if possible.
method
src.werkzeug.wrappers.response.Response.freeze() -> NoneMake the response object ready to be pickled.
method
src.werkzeug.wrappers.response.Response.get_app_iter(environ:WSGIEnvironment) -> t.Iterable[bytes]Returns the application iterator for the given environ.
method
src.werkzeug.wrappers.response.Response.get_wsgi_response(environ:WSGIEnvironment) -> tuple[t.Iterable[bytes], str, list[tuple[str, str]]]Returns the final WSGI response as tuple.
method
src.werkzeug.wrappers.response.Response.make_sequence() -> NoneConverts the response iterator in a list.
method
src.werkzeug.wrappers.response.Response.set_data(value:bytes | str) -> NoneSets a new string as response.
method
src.werkzeug.wrappers.response.Response.stream() -> ResponseStreamThe response iterable as write-only stream.
class
src.werkzeug.wsgi.LimitedStreamWrap a stream so that it doesn't read more than a given limit.
method
src.werkzeug.wsgi.LimitedStream.tell() -> intReturn the current stream position.
func
src.werkzeug.wsgi.get_content_length(environ:WSGIEnvironment) -> int | NoneReturn the ``Content-Length`` header value as an int.
func
src.werkzeug.wsgi.get_path_info(environ:WSGIEnvironment) -> strReturn ``PATH_INFO`` from the WSGI environment.
func
src.werkzeug.wsgi.responder(f:t.Callable[..., WSGIApplication]) -> WSGIApplicationMarks a function as responder.
func
src.werkzeug.wsgi.wrap_file(environ:WSGIEnvironment, file:t.IO[bytes], buffer_size:int=8192) -> t.Iterable[bytes]Wraps a file.
About this data
These signatures were extracted from the public source of pallets/werkzeug
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.