MCPcopy Create free account
hub / github.com/EasyIME/PIME / static_url

Method static_url

python/python3/tornado/web.py:1551–1587  ·  view source on GitHub ↗

Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``

(
        self, path: str, include_host: Optional[bool] = None, **kwargs: Any
    )

Source from the content-addressed store, hash-verified

1549 )
1550
1551 def static_url(
1552 self, path: str, include_host: Optional[bool] = None, **kwargs: Any
1553 ) -> str:
1554 """Returns a static URL for the given relative static file path.
1555
1556 This method requires you set the ``static_path`` setting in your
1557 application (which specifies the root directory of your static
1558 files).
1559
1560 This method returns a versioned url (by default appending
1561 ``?v=<signature>``), which allows the static files to be
1562 cached indefinitely. This can be disabled by passing
1563 ``include_version=False`` (in the default implementation;
1564 other static file implementations are not required to support
1565 this, but they may support other options).
1566
1567 By default this method returns URLs relative to the current
1568 host, but if ``include_host`` is true the URL returned will be
1569 absolute. If this handler has an ``include_host`` attribute,
1570 that value will be used as the default for all `static_url`
1571 calls that do not pass ``include_host`` as a keyword argument.
1572
1573 """
1574 self.require_setting("static_path", "static_url")
1575 get_url = self.settings.get(
1576 "static_handler_class", StaticFileHandler
1577 ).make_static_url
1578
1579 if include_host is None:
1580 include_host = getattr(self, "include_host", False)
1581
1582 if include_host:
1583 base = self.request.protocol + "://" + self.request.host
1584 else:
1585 base = ""
1586
1587 return base + get_url(self.settings, path, **kwargs)
1588
1589 def require_setting(self, name: str, feature: str = "this feature") -> None:
1590 """Raises an exception if the given app setting is not defined."""

Callers 5

render_linked_jsMethod · 0.95
render_linked_cssMethod · 0.95
getMethod · 0.80
getMethod · 0.80
getMethod · 0.80

Calls 2

require_settingMethod · 0.95
getMethod · 0.45

Tested by 3

getMethod · 0.64
getMethod · 0.64
getMethod · 0.64