mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Tweak media proxying
This commit is contained in:
parent
8613cc0206
commit
15ad5b08c4
2 changed files with 5 additions and 4 deletions
5
app.py
5
app.py
|
@ -236,8 +236,9 @@ def microblogpub_jsonld():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/p/<path:url>")
|
@app.route("/p/<scheme>/<path:url>")
|
||||||
def proxy(url: str) -> Any:
|
def proxy(scheme: str, url: str) -> Any:
|
||||||
|
url = f"{scheme}://{url}"
|
||||||
req_headers = {
|
req_headers = {
|
||||||
k: v
|
k: v
|
||||||
for k, v in dict(request.headers).items()
|
for k, v in dict(request.headers).items()
|
||||||
|
|
|
@ -248,11 +248,11 @@ def _get_file_url(url, size, kind) -> str:
|
||||||
_FILE_URL_CACHE[k] = out
|
_FILE_URL_CACHE[k] = out
|
||||||
return out
|
return out
|
||||||
|
|
||||||
# MEDIA_CACHE.cache(url, kind)
|
|
||||||
_logger.error(f"cache not available for {url}/{size}/{kind}")
|
_logger.error(f"cache not available for {url}/{size}/{kind}")
|
||||||
if url.startswith(BASE_URL):
|
if url.startswith(BASE_URL):
|
||||||
return url
|
return url
|
||||||
return f"/p/{url}"
|
p = urlparse(url)
|
||||||
|
return f"/p/{p.scheme}" + p._replace(scheme="").geturl()[1:]
|
||||||
|
|
||||||
|
|
||||||
@filters.app_template_filter()
|
@filters.app_template_filter()
|
||||||
|
|
Loading…
Reference in a new issue