nobsdelivr/app.py
Kumi c4054c1374
feat: add Flask proxy app for cdn.jsdelivr.net
Introduce a simple Flask app that proxies requests to cdn.jsdelivr.net.
Includes basic routing for home and proxy endpoints, and a template
render for the home page explaining usage. Added Flask to
requirements.txt and updated .gitignore to exclude venv and __pycache__.
2024-08-03 08:40:59 +02:00

16 lines
No EOL
369 B
Python

from flask import Flask, redirect, render_template, request
app = Flask(__name__)
@app.route('/')
def home():
domain = request.url_root
return render_template('index.html', domain=domain)
@app.route('/<path:url>')
def proxy(url):
jsdelivr_url = f'https://cdn.jsdelivr.net/{url}'
return redirect(jsdelivr_url)
if __name__ == '__main__':
app.run()