Loading nginx_configs/ipmi_fileserve.conf +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ server { } # Serves ISOs, because BMC virtual disk mount commonly requires range request support, which Flash + Gunicorn itself cannot natively provide. location /iso/ { alias /opt/fileserve/iso_files/; alias /opt/fileserve/src/iso/; autoindex on; sendfile on; tcp_nopush on; Loading src/app.py +9 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import threading import time import requests import io, hashlib, hmac import shutil from urllib.parse import urlparse Loading @@ -26,7 +27,7 @@ def cleanup_files(): file_path = os.path.join(HASH_FOLDER, file) if os.path.isfile(file_path) and current_time - os.path.getctime(file_path) > 72 * 3600: os.remove(file_path) time.sleep(3600) # Check every hour time.sleep(60) # Check every minute threading.Thread(target=cleanup_files, daemon=True).start() Loading Loading @@ -78,6 +79,7 @@ def index(): filename = os.path.basename(urlparse(file_url).path) threading.Thread(target=download_iso, args=(file_url, filename), daemon=True).start() return redirect(url_for('index')) return render_template_string(template) Loading Loading @@ -115,5 +117,11 @@ def file_list(): return "".join(file_list) @app.route('/diskspace') def diskspace(): total, used, freespace = shutil.disk_usage("/") return f"{freespace // (2 ** 30)}" if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=8081) src/index.template.html +11 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ <button type="submit">Download</button> </form> </div> <div> <p onclick="fetchDiskSpace()">Free space available on the server is: <span id="freespace">unknown</span>GB</p> </div> <div> <h3>Available Files:</h3> <table> Loading Loading @@ -62,7 +65,15 @@ document.getElementById('file-list').innerHTML = data; }); } function fetchDiskSpace() { fetch('/diskspace').then(response => response.text()).then(data => { document.getElementById('freespace').innerHTML = data; }); } //refresh page every 1s setInterval(fetchFileList, 1000); fetchFileList(); fetchDiskSpace(); </script> No newline at end of file Loading
nginx_configs/ipmi_fileserve.conf +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ server { } # Serves ISOs, because BMC virtual disk mount commonly requires range request support, which Flash + Gunicorn itself cannot natively provide. location /iso/ { alias /opt/fileserve/iso_files/; alias /opt/fileserve/src/iso/; autoindex on; sendfile on; tcp_nopush on; Loading
src/app.py +9 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import threading import time import requests import io, hashlib, hmac import shutil from urllib.parse import urlparse Loading @@ -26,7 +27,7 @@ def cleanup_files(): file_path = os.path.join(HASH_FOLDER, file) if os.path.isfile(file_path) and current_time - os.path.getctime(file_path) > 72 * 3600: os.remove(file_path) time.sleep(3600) # Check every hour time.sleep(60) # Check every minute threading.Thread(target=cleanup_files, daemon=True).start() Loading Loading @@ -78,6 +79,7 @@ def index(): filename = os.path.basename(urlparse(file_url).path) threading.Thread(target=download_iso, args=(file_url, filename), daemon=True).start() return redirect(url_for('index')) return render_template_string(template) Loading Loading @@ -115,5 +117,11 @@ def file_list(): return "".join(file_list) @app.route('/diskspace') def diskspace(): total, used, freespace = shutil.disk_usage("/") return f"{freespace // (2 ** 30)}" if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=8081)
src/index.template.html +11 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ <button type="submit">Download</button> </form> </div> <div> <p onclick="fetchDiskSpace()">Free space available on the server is: <span id="freespace">unknown</span>GB</p> </div> <div> <h3>Available Files:</h3> <table> Loading Loading @@ -62,7 +65,15 @@ document.getElementById('file-list').innerHTML = data; }); } function fetchDiskSpace() { fetch('/diskspace').then(response => response.text()).then(data => { document.getElementById('freespace').innerHTML = data; }); } //refresh page every 1s setInterval(fetchFileList, 1000); fetchFileList(); fetchDiskSpace(); </script> No newline at end of file