So how do programs of yore run as web servers when they didn't include a http stack? You run a dedicated server process (Apache, Nginx, ...) which calls your program to generate the response.
The oldest protocol. The server executes a program, passing request info as env and request body as stdin, expecting a response (including headers) on stdout.
FastCGI, because fork-exec for every request is too costly. Basically a worker pool of processes that are kept alive, communication (request,response) is over sockets
SimpleCGI, like FCGI but simpler(?) to parse
Not to be confused with the framework of the same name, a simplish binary packet protocol for between the server and framework.
Binary packet protocol between web server and application thing.
There are others, like for Perl, Clojure, Common Lisp, ...
Web Server Gateway Interface, Python specific.
The python function signature:
request as env/dict, response through callback/return string.
Uses a separate middleware process to manage lifetimes
and translate from HTTP/other to the function call.
Apache <-HTTP-> uwsgi <-function call-> app