Blob


1 #!/usr/bin/env perl
3 use strict;
4 use warnings;
5 use v5.10;
7 my $path = $ENV{'PATH_INFO'};
8 my $script_path = $ENV{'SCRIPT_NAME'};
9 my $server_name = $ENV{'SERVER_NAME'};
11 sub reply {
12 my ($code, $meta) = @_;
13 print "$code $meta\r\n";
14 if ($code != 20) {
15 exit(0);
16 }
17 }
19 if (! defined($path) || $path eq '') {
20 reply 20, 'text/gemini';
21 print <<EOF;
22 # gemini bin
24 Append a clbin.com URL to see it via your preferred gemini browser!
26 For example: gemini://${server_name}${script_path}/clbin.com/XYZ
28 --eof
29 EOF
30 exit(0);
31 }
33 # trim initial slash so we have only the hostname
34 $path =~ s,^/,,;
36 # implement multiple bins eventually...
37 if ($path =~ m,^clbin.com/.*,) {
38 reply 20, 'text/plain';
39 exec 'curl', 'https://'.$path;
40 } else {
41 reply 59, 'bin not supported';
42 }