nocdnbs/app.py

22 lines
453 B
Python
Raw Normal View History

from flask import Flask, render_template, request
from urllib.request import urlopen
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://cdnjs.cloudflare.com/{url}'
response = urlopen(jsdelivr_url)
content = response.read()
return content
if __name__ == '__main__':
app.run()