feat(proxy): return content instead of redirecting

Updated the proxy route to fetch and return the content from
jsdelivr instead of just redirecting to the URL. This change
allows the application to handle and manipulate the content
before sending it to the client, which provides more control
over the data flow.
This commit is contained in:
Kumi 2024-08-03 16:26:34 +02:00
parent e6373d0535
commit 8076dcd937
Signed by: kumi
GPG key ID: ECBCC9082395383F

8
app.py
View file

@ -1,5 +1,7 @@
from flask import Flask, redirect, render_template, request
from urllib.request import urlopen
app = Flask(__name__)
@app.route('/')
@ -10,7 +12,11 @@ def home():
@app.route('/<path:url>')
def proxy(url):
jsdelivr_url = f'https://cdn.jsdelivr.net/{url}'
return redirect(jsdelivr_url)
response = urlopen(jsdelivr_url)
content = response.read()
return content
if __name__ == '__main__':
app.run()