commit c4054c1374b101702cbf7d8d8159e1a46799c50e Author: Kumi Date: Sat Aug 3 08:40:59 2024 +0200 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__. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ea05a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv/ +__pycache__/ \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..6d90845 --- /dev/null +++ b/app.py @@ -0,0 +1,16 @@ +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('/') +def proxy(url): + jsdelivr_url = f'https://cdn.jsdelivr.net/{url}' + return redirect(jsdelivr_url) + +if __name__ == '__main__': + app.run() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8ab6294 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..8cc4f8d --- /dev/null +++ b/templates/index.html @@ -0,0 +1,33 @@ + + + + + + nobsdelivr + + + +
+

Welcome to nobsdelivr

+

+ nobsdelivr is a simple proxy to cdn.jsdelivr.net. Use it to proxy your + requests to the CDN. +

+
+

+ To use the proxy, simply replace + https://cdn.jsdelivr.net with {{ domain }} in + the URL. +

+

Example:

+ {{ domain }}npm/bootstrap@5.1.3/dist/css/bootstrap.min.css +
+ + +