duck.routes.route_blueprintยถ
Module for route arrangements using Blueprint. This acts as a set of routes, much like how Flaskโs blueprints organize routes in a module.
Example:
app = Blueprint(location=__file__, name="products", urlpatterns=...)
Note
To resolve a url for a blueprint, the name should be {blueprint_name}.{path_name} .e.g.,
"api.followers" for blueprint named api and a path registered with name followers
Module Contentsยถ
Classesยถ
Mini application for storing route information. |
APIยถ
- class duck.routes.route_blueprint.Blueprint(location: str, name: str, urlpatterns: Optional[List[duck.urls.URLPattern]] = None, prepend_name_to_urls: bool = True, static_dir: str = 'static', template_dir: str = 'templates', enable_static_dir: bool = True, enable_template_dir: bool = True, is_builtin: bool = False)[source]ยถ
Mini application for storing route information.
Initialization
Initialize the Blueprint.
- Parameters:
location โ The absolute path to where the blueprint is located.
name โ A valid string representing the blueprintโs name.
urlpatterns โ List of urlpatterns created using duck.urls.path or re_path.
prepend_name_to_urls โ Whether to prepend name to urlpatterns. Defaults to True.
static_dir โ The location of static files within the blueprint base directory.
template_dir โ The template directory for the blueprint.
enable_static_dir โ Boolean on whether to enable commands like
duck collectstaticto access the blueprint staticfiles.enable_template_dir โ Expose the template dir for template resolving.
is_builtin โ Flag the route blueprint as an internal builtin blueprint, Defaults to False (optional).
- __namesยถ
[]
Names of all created blueprints.
- add_urlpattern(urlpattern: duck.urls.URLPattern)[source]ยถ
Adds a url pattern to the blueprint urlpatterns collection.
โฆ admonition:: Notes
This reconfigures the urlpattern to belong to the blueprint before adding the url pattern.
- property root_directory: strยถ
Returns the absolute blueprint root path.
- property root_directory_name: strยถ
Returns the blueprint root path name.