Python3 - http.server
Using CGI with http.server
This invocation started up a python http server with CGI:
python3 -m http.server --bind localhost --cgi 8000
In order to use the CGI, I had to create a /cgi-bin
folder, which is one of the standard paths for python’s http server.
A short shell script hello.sh
:The extra newline seems to be important for HTTP parsing by the browser.
#!/usr/bin/env bash
echo "Content-Type: text/html"
echo ""
echo "<!doctype html><title>Hello</title><h2>hello world today</h2>"
After making the script executable, I can navigate to localhost:8000/cgi-bin/hello.sh
to see “hello world today”.