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

Function url_for

src/flask/helpers.py:195–246  ·  src/flask/helpers.py::url_for

Generate a URL to the given endpoint with the given values. This requires an active request or application context, and calls :meth:`current_app.url_for() <flask.Flask.url_for>`. See that method for full documentation. :param endpoint: The endpoint name associated with the URL to

(
    endpoint: str,
    *,
    _anchor: str | None = None,
    _method: str | None = None,
    _scheme: str | None = None,
    _external: bool | None = None,
    **values: t.Any,
)

Source from the content-addressed store, hash-verified

193
194
195def url_for(
196 endpoint: str,
197 *,
198 _anchor: str | None = None,
199 _method: str | None = None,
200 _scheme: str | None = None,
201 _external: bool | None = None,
202 **values: t.Any,
203) -> str:
204 class="st">"""Generate a URL to the given endpoint with the given values.
205
206 This requires an active request or application context, and calls
207 :meth:`current_app.url_for() <flask.Flask.url_for>`. See that method
208 for full documentation.
209
210 :param endpoint: The endpoint name associated with the URL to
211 generate. If this starts with a ``.``, the current blueprint
212 name (if any) will be used.
213 :param _anchor: If given, append this as ``class="cm">#anchor`` to the URL.
214 :param _method: If given, generate the URL associated with this
215 method for the endpoint.
216 :param _scheme: If given, the URL will have this scheme if it is
217 external.
218 :param _external: If given, prefer the URL to be internal (False) or
219 require it to be external (True). External URLs include the
220 scheme and domain. When not in an active request, URLs are
221 external by default.
222 :param values: Values to use for the variable parts of the URL rule.
223 Unknown keys are appended as query string arguments, like
224 ``?a=b&c=d``.
225
226 .. versionchanged:: 2.2
227 Calls ``current_app.url_for``, allowing an app to override the
228 behavior.
229
230 .. versionchanged:: 0.10
231 The ``_scheme`` parameter was added.
232
233 .. versionchanged:: 0.9
234 The ``_anchor`` and ``_method`` parameters were added.
235
236 .. versionchanged:: 0.9
237 Calls ``app.handle_url_build_error`` on build errors.
238 class="st">"""
239 return current_app.url_for(
240 endpoint,
241 _anchor=_anchor,
242 _method=_method,
243 _scheme=_scheme,
244 _external=_external,
245 **values,
246 )
247
248
249def redirect(

Callers 8

test_custom_convertersFunction · 0.90
createFunction · 0.90
updateFunction · 0.90
deleteFunction · 0.90
wrapped_viewFunction · 0.90
registerFunction · 0.90
loginFunction · 0.90
logoutFunction · 0.90

Calls 1

url_forMethod · 0.80

Tested by 1

test_custom_convertersFunction · 0.72