return [200, [ "Content-Type" => "text/html; charset=utf-8"], [ $member->contents ] ];
####
use strict;
use Dancer2;
use Archive::Zip;
any '/**' => \&handler;
sub handler {
my($context)=@_;
my $zip = Archive::Zip->new;
$zip->read("eco.zip") == Archive::Zip::AZ_OK or die "cannot read zip\n";
my $path = $context->request->path;
$path =~ s|^/||;
my $member = $zip->memberNamed($path) or die "no such member: $path\n";
my $type;
$type = "text/html; charset=utf-8" if $path =~ /\.html$/;
$type = "image/jpg" if $path =~ /\.jpg$/;
$type = "image/png" if $path =~ /\.png$/;
die "unhandled file: $path\n" unless $type;
response_header "Content-Type" => $type;
return $member->contents;
};
start;