simpleStatic.pl
#!/usr/bin/perl
use strict;
use warnings FATAL => qw(all);
use Sloop::Server;
use Sloop::Static;
my $sloop = Sloop::Server->new (
client_constructor => Sloop::Client::Regular->new (
@_,
maxage => 21600
)
);
$sloop->{handlers} = {
'/' => sub {
Sloop::Static::directory (
shift,
path => '/var/www',
mimetype => 'text/html; charset=UTF-8'
);
},
css => sub {
Sloop::Static::directory (
shift,
path => '/var/www/css',
mimetype => 'text/css',
index => 1
);
},
images => sub {
Sloop::Static::directory (
shift,
path => '/var/www/images',
maxage => 3600
);
},
js => sub {
Sloop::Static::directory (
shift,
path => '/var/www/js',
mimetype => 'application/javascript',
index => 1
);
}
};
$sloop->run;