App-lupapona

 view release on metacpan or  search on metacpan

script/lupa-pona  view on Meta::CPAN

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
} elsif ($authority and $host and $host ne $url_host or $port ne $url_port) {
  $stream->write("53 Unsupported proxy request for $url; we just serve $host:$port\r\n");
} elsif (not $path) {
  $stream->write("31 $url/\r\n"); # enforce trailing slash
} elsif ($path eq "/") {
  $stream->write("20 text/gemini; charset=UTF-8\r\n");
  $stream->write("Welcome to Lupa Pona!\n");
  for (read_dir(".")) {
    next if $_ eq $cert_file;
    next if $_ eq $key_file;
    next if /~$/; # Emacs backup files
    $stream->write("=> $_\n") if -f;
  }
} elsif ($path eq "/$cert_file" or $path eq "/$key_file") {
  $stream->write("50 Forbidden\n");
} elsif ($path =~ m!^/([^/]+)$!) {
  my $file = decode_utf8(uri_unescape($1));
  if (-f $file) {
    my $mime = globs($file) || mime_type($file);
    $mime .= "; charset=$encoding" if $mime =~ /^text\// and $encoding;
    $stream->write("20 $mime\r\n");



( run in 0.252 second using v1.01-cache-2.11-cpan-cba739cd03b )