~int80h/gemserv

ref: c7677ce2f28d5013938ac2748d74f10fdddfb55c gemserv/cgi-scripts/scgi/scgi.py -rwxr-xr-x 663 bytes
c7677ce2int 80h Added .build.yml 1 year, 9 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/local/bin/python3.6
import scgi
import scgi.scgi_server

class TimeHandler(scgi.scgi_server.SCGIHandler):
    def produce(self, env, bodysize, input, output):
       header = "20\ttext/gemini\r\n"
       hi = "python\n"
       output.write(header.encode())
       output.write(hi.encode())

    # Main program: create an SCGIServer object to
    # listen on port 4000.  We tell the SCGIServer the
    # handler class that implements our application.
server = scgi.scgi_server.SCGIServer(
    handler_class=TimeHandler,
    port=4000
                        )
    # Tell our SCGIServer to start servicing requests.
    # This loops forever.
server.serve()