Hi, I’m Erika Rowland (a.k.a. erikareads). Hi, I’m Erika. I’m an Ops-shaped Software Engineer, Toolmaker, and Resilience Engineering fan. I like Elixir and Gleam, Reading, and Design. She/Her. Constellation Webring Published on

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”.


Constellation Webring