Skip to content

Instantly share code, notes, and snippets.

@apnea
Created February 5, 2026 10:23
Show Gist options
  • Select an option

  • Save apnea/cffd9863b1f3b9d6672394088e149879 to your computer and use it in GitHub Desktop.

Select an option

Save apnea/cffd9863b1f3b9d6672394088e149879 to your computer and use it in GitHub Desktop.
server a directory as a sorted list of links
#!/bin/bash
python3 -c "
import os, urllib.parse
files = [f for f in os.listdir('.') if os.path.isfile(f)]
files.sort(key=lambda x: os.path.getmtime(x), reverse=True)
with open('index.html', 'w') as out:
out.write('<html><body><h2>Files (newest first)</h2>')
for f in files:
url = urllib.parse.quote(f)
out.write(f'<a href=\"{url}\">{f}</a><br>\n')
out.write('</body></html>')
"
services:
python:
container_name: httpd
volumes:
- /myfiles:/usr/local/apache2/htdocs:ro
ports:
- 9090:80
image: httpd
networks: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment