quart.routing module

class quart.routing.AnyConverter(*items: str)

Bases: quart.routing.BaseConverter

class quart.routing.BaseConverter

Bases: object

regex = '[^/]+'
to_python(value: str) → Any
to_url(value: Any) → str
weight = 100
exception quart.routing.BuildError(endpoint: str, rules: List[Rule], values: Optional[Dict] = None, method: Optional[str] = None)

Bases: Exception

class quart.routing.FloatConverter(min: Optional[float] = None, max: Optional[float] = None)

Bases: quart.routing.BaseConverter

regex = '\\d+\\.\\d+'
to_python(value: str) → float
to_url(value: float) → str
weight = 50
class quart.routing.IntegerConverter(fixed_digits: Optional[int] = None, min: Optional[int] = None, max: Optional[int] = None)

Bases: quart.routing.BaseConverter

regex = '\\d+'
to_python(value: str) → int
to_url(value: int) → str
weight = 50
class quart.routing.Map(host_matching: bool = False)

Bases: object

add(rule: quart.routing.Rule) → None
bind(secure: bool, server_name: str) → quart.routing.MapAdapter
bind_to_request(secure: bool, server_name: str, method: str, path: str, query_string: bytes, websocket: bool, root_path: str) → quart.routing.MapAdapter
default_converters = {'any': <class 'quart.routing.AnyConverter'>, 'default': <class 'quart.routing.StringConverter'>, 'float': <class 'quart.routing.FloatConverter'>, 'int': <class 'quart.routing.IntegerConverter'>, 'path': <class 'quart.routing.PathConverter'>, 'string': <class 'quart.routing.StringConverter'>, 'uuid': <class 'quart.routing.UUIDConverter'>}
iter_rules(endpoint: Optional[str] = None) → Iterator[quart.routing.Rule]
class quart.routing.MapAdapter(map: quart.routing.Map, secure: bool, server_name: str, method: Optional[str] = None, path: Optional[str] = None, query_string: Optional[bytes] = None, websocket: bool = False, root_path: str = '')

Bases: object

allowed_methods() → Set[str]
build(endpoint: str, values: Optional[dict] = None, method: Optional[str] = None, scheme: Optional[str] = None, external: bool = False) → str
match() → Tuple[quart.routing.Rule, Dict[str, Any]]
class quart.routing.PathConverter

Bases: quart.routing.BaseConverter

regex = '[^/].*?'
weight = 200
class quart.routing.Rule(rule: str, methods: Set[str], endpoint: str, strict_slashes: bool = True, defaults: Optional[dict] = None, host: Optional[str] = None, *, provide_automatic_options: bool = True, is_websocket: bool = False)

Bases: object

bind(map: quart.routing.Map) → None

Bind the Rule to a Map and compile it.

build(**values: Any) → str

Build this rule into a path using the values given.

property build_key

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).

buildable(values: Optional[dict] = None, method: Optional[str] = None) → bool

Return True if this rule can build with the values and method.

match(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.

property match_key

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 or reject.

  • Then by the number of parts, with more complex (more parts) first.

  • Finally by the weights themselves. Note that weights are also sub keyed by converter first then weight second.

provides_defaults_for(rule: quart.routing.Rule, **values: Any) → bool

Returns true if this rule provides defaults for the argument and values.

class quart.routing.StringConverter(minlength: int = 1, maxlength: Optional[int] = None, length: Optional[int] = None)

Bases: quart.routing.BaseConverter

class quart.routing.UUIDConverter

Bases: quart.routing.BaseConverter

regex = '[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}'
to_python(value: str) → uuid.UUID
to_url(value: uuid.UUID) → str
exception quart.routing.ValidationError

Bases: Exception

class quart.routing.VariablePart(converter, arguments, name)

Bases: tuple

property arguments

Alias for field number 1

property converter

Alias for field number 0

property name

Alias for field number 2


alias of quart.routing.Weight