diff --git a/src/index.py b/src/index.py index 6fdb30e..d1f8bc7 100644 --- a/src/index.py +++ b/src/index.py @@ -9,19 +9,39 @@ import gnupg main_pages = Blueprint("main", __name__) + +def download_file(url, file): + os.makedirs("/app/static/", exist_ok=True) + r = requests.get(url, allow_redirects=True) + open(file, "wb").write(r.content) + + +def cache_bootstrap(): + download_file( + "https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css", + "/app/static/bootstrap.min.css", + ) + download_file( + "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css", + "/app/static/bootstrap-icons.css", + ) + download_file( + "https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js", + "/app/static/bootstrap.bundle.min.js", + ) + + # Bootstrap CSS BOOTSTRAP = [ Reference( - "https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css", + "/static/bootstrap.min.css", "stylesheet", ), Reference( - "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css", + "/static/bootstrap-icons.css", "stylesheet", ), - Script( - src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" - ), + Script(src="/static/bootstrap.bundle.min.js"), ] # Encrypt msg with GPG diff --git a/src/main.py b/src/main.py index e929542..77954a5 100644 --- a/src/main.py +++ b/src/main.py @@ -12,4 +12,7 @@ app.register_blueprint(asset_pages, url_prefix="/assets") if __name__ == "__main__": + from index import cache_bootstrap + + cache_bootstrap() app.run(host="0.0.0.0", port=1030, debug=True, threaded=True)