Let’s say you have a command that produces some output on standard output. Here’s how you could implement it in your config file:

package App::Phoebe;
use Modern::Perl;
our (@extensions, @main_menu);
push(@extensions, \&serve_date);
sub serve_date {
  my $stream = shift;
  my $url = shift;
  my $headers = shift;
  my $host = host_regex();
  my $port = port($stream);
  if ($url =~ m!^gemini://($host)(?::$port)?/do/date$!) {
    $stream->write("20 text/plain\r\n");
    $stream->write(qx(date --iso-8601));
    return 1;
  }
  return;
}

This answers to the “do/date” URL and responds with the output of “date --iso-8601”. 🚀