Automatically render any index.html files available in the path

This commit is contained in:
Ana Custura 2026-04-01 10:41:31 +01:00
parent 270c102d27
commit 8c64711e1c

View file

@ -128,6 +128,10 @@ def files(path):
render_files = [] render_files = []
if os.path.exists(current_path): if os.path.exists(current_path):
render_files = get_files_in_path(current_path) render_files = get_files_in_path(current_path)
filenames = [x['name'] for x in render_files]
if 'index.html' in filenames:
index_path = render_files[filenames.index('index.html')]['path']
return redirect(url_for('serve_file', filepath=index_path))
else: else:
return redirect(url_for('files', path="")) return redirect(url_for('files', path=""))
return render_template('usb-file-viewer.html', title='File Viewer', current_path=current_path, render_files=render_files, get_setting=get_setting) return render_template('usb-file-viewer.html', title='File Viewer', current_path=current_path, render_files=render_files, get_setting=get_setting)