MCPcopy
hub / github.com/pallets/flask / add_url_rule

Method add_url_rule

src/flask/sansio/blueprints.py:413–441  ·  src/flask/sansio/blueprints.py::Blueprint.add_url_rule

Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for full documentation. The URL rule is prefixed with the blueprint's URL prefix. The endpoint name, used with :func:`url_for`, is prefixed with the blueprint's name.

(
        self,
        rule: str,
        endpoint: str | None = None,
        view_func: ft.RouteCallable | None = None,
        provide_automatic_options: bool | None = None,
        **options: t.Any,
    )

Source from the content-addressed store, hash-verified

411
412 @setupmethod
413 def add_url_rule(
414 self,
415 rule: str,
416 endpoint: str | None = None,
417 view_func: ft.RouteCallable | None = None,
418 provide_automatic_options: bool | None = None,
419 **options: t.Any,
420 ) -> None:
421 class="st">"""Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for
422 full documentation.
423
424 The URL rule is prefixed with the blueprint&class="cm">#x27;s URL prefix. The endpoint name,
425 used with :func:`url_for`, is prefixed with the blueprint&class="cm">#x27;s name.
426 class="st">"""
427 if endpoint and class="st">"." in endpoint:
428 raise ValueError(class="st">"&class="cm">#x27;endpoint' may not contain a dot '.' character.")
429
430 if view_func and hasattr(view_func, class="st">"__name__") and class="st">"." in view_func.__name__:
431 raise ValueError(class="st">"&class="cm">#x27;view_func' name may not contain a dot '.' character.")
432
433 self.record(
434 lambda s: s.add_url_rule(
435 rule,
436 endpoint,
437 view_func,
438 provide_automatic_options=provide_automatic_options,
439 **options,
440 )
441 )
442
443 @setupmethod
444 def app_template_filter(

Callers 3

add_url_ruleMethod · 0.45
registerMethod · 0.45

Calls 1

recordMethod · 0.95