SCGI
This commit is contained in:
16
cgi-scripts/scgi/scgi.pl
Executable file
16
cgi-scripts/scgi/scgi.pl
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
|
||||
use SCGI;
|
||||
use IO::Socket;
|
||||
|
||||
my $socket = IO::Socket::INET->new(Listen => 5, ReuseAddr => 1, LocalPort => 4001)
|
||||
or die "cannot bind to port 4001: $!";
|
||||
|
||||
my $scgi = SCGI->new($socket, blocking => 1);
|
||||
|
||||
while (my $request = $scgi->accept) {
|
||||
$request->read_env;
|
||||
read $request->connection, my $body, $request->env->{CONTENT_LENGTH};
|
||||
print { $request->connection } "20\ttext/gemini\r\nperl\n";
|
||||
}
|
||||
21
cgi-scripts/scgi/scgi.py
Executable file
21
cgi-scripts/scgi/scgi.py
Executable file
@@ -0,0 +1,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()
|
||||
Reference in New Issue
Block a user