package Sitemap;
use nginx;
use LWP::Simple;
 
our $basedir="/var/www/www.example1.com";
 
sub handler {
  my $r=shift;
  my $cache_dir="/tmp";  # Cache directory where minified files will be kept
  my $cache_file=$r->uri;
  $cache_file=~s!/!_!g;
  $cache_file=join("/", $cache_dir, $cache_file);
  my $uri=$r->uri;
  my $filename=$r->filename;
 
  return DECLINED unless -f $filename;
 
  if (! -f $cache_file) {
    `python sitemap_gen.py` # Assumes that google sitemap generator is in the same directory
  }
  $r->sendfile($cache_file);
  return OK;

}
 
1;

__END__