Created
February 5, 2026 10:23
-
-
Save apnea/cffd9863b1f3b9d6672394088e149879 to your computer and use it in GitHub Desktop.
server a directory as a sorted list of links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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