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:
parent
e6373d0535
commit
8076dcd937
1 changed files with 7 additions and 1 deletions
8
app.py
8
app.py
|
@ -1,5 +1,7 @@
|
||||||
from flask import Flask, redirect, render_template, request
|
from flask import Flask, redirect, render_template, request
|
||||||
|
|
||||||
|
from urllib.request import urlopen
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
@ -10,7 +12,11 @@ def home():
|
||||||
@app.route('/<path:url>')
|
@app.route('/<path:url>')
|
||||||
def proxy(url):
|
def proxy(url):
|
||||||
jsdelivr_url = f'https://cdn.jsdelivr.net/{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__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run()
|
Loading…
Reference in a new issue