Serve the Current Directory Over HTTP with Python 3
Serve a folder over HTTP with python3 -m http.server 8123 --directory site --bind 127.0.0.1. The --directory option needs Python 3.7 or later.
You want to look at a folder of files or a static site in a browser, and installing a web server for it is too much.
mkdir -p site
echo '<h1>hello</h1>' > site/index.html
echo 'plain file' > site/notes.txt
python3 -m http.server 8123 --directory site --bind 127.0.0.1 > access.log 2>&1 &
srv=$!
sleep 1
curl -s localhost:8123/
curl -s localhost:8123/notes.txt
curl -s -o /dev/null -w '%{http_code}\n' localhost:8123/missing
kill "$srv"
grep -o '"GET[^"]*" [0-9]*' access.log<h1>hello</h1>
plain file
404
"GET / HTTP/1.1" 200
"GET /notes.txt HTTP/1.1" 200
"GET /missing HTTP/1.1" 404The http.server module serves the files under the chosen directory, and --directory sets it without a cd. --bind 127.0.0.1 keeps the server reachable from this machine only. The run fetched index.html for the root path, a plain file, and a 404 for a missing path, and the log lines show each request with its status. See http.server in the Python documentation.
It is a development convenience: no TLS, no authentication, no access rules, and a folder without an index file is listed in full. Without --bind it listens on all interfaces, so anyone on the network can read the folder. The log lines also carry a timestamp, which the run trims with grep -o.