fix(proxy): correct URL composition for CDNJS
Updated the URL construction within the proxy function to correctly reference CDNJS URLs. Previously the variable name mistakenly suggested an old CDN (jsdelivr), potentially leading to confusion and incorrect URL referencing. This change ensures accuracy and consistency when fetching and streaming resources.
This commit is contained in:
parent
c519a056c2
commit
ce9e34f55e
1 changed files with 3 additions and 3 deletions
6
app.py
6
app.py
|
@ -16,13 +16,13 @@ def home():
|
||||||
|
|
||||||
@app.route("/<path:url>")
|
@app.route("/<path:url>")
|
||||||
def proxy(url):
|
def proxy(url):
|
||||||
jsdelivr_url = f"https://cdnjs.cloudflare.com/{url}"
|
cdnjs_url = f"https://cdnjs.cloudflare.com/{url}"
|
||||||
|
|
||||||
def generate():
|
def generate():
|
||||||
# Subfunction to allow streaming the data instead of
|
# Subfunction to allow streaming the data instead of
|
||||||
# downloading all of it at once
|
# downloading all of it at once
|
||||||
try:
|
try:
|
||||||
with urlopen(unquote(url)) as data:
|
with urlopen(unquote(cdnjs_url)) as data:
|
||||||
while True:
|
while True:
|
||||||
chunk = data.read(1024 * 1024)
|
chunk = data.read(1024 * 1024)
|
||||||
if not chunk:
|
if not chunk:
|
||||||
|
@ -32,7 +32,7 @@ def proxy(url):
|
||||||
abort(e.code)
|
abort(e.code)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with urlopen(unquote(jsdelivr_url)) as data:
|
with urlopen(unquote(cdnjs_url)) as data:
|
||||||
content_type = data.headers["content-type"]
|
content_type = data.headers["content-type"]
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
abort(e.code)
|
abort(e.code)
|
||||||
|
|
Loading…
Reference in a new issue