Takes path relative to static/ and constructs url to that resource with hash.
(path)
| 142 | @functools.cache |
| 143 | @public |
| 144 | def static_url(path): |
| 145 | """Takes path relative to static/ and constructs url to that resource with hash.""" |
| 146 | pardir = os.path.pardir |
| 147 | fullpath = os.path.abspath(os.path.join(__file__, pardir, pardir, pardir, pardir, "static", path)) |
| 148 | with open(fullpath, "rb") as in_file: |
| 149 | digest = hashlib.md5(in_file.read()).hexdigest() |
| 150 | return f"/static/{path}?v={digest}" |
| 151 | |
| 152 | |
| 153 | class DynamicDocument: |
no test coverage detected