File: example.pl

package info (click to toggle)
libhttp-server-simple-static-perl 0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 96 kB
  • sloc: perl: 151; makefile: 2
file content (30 lines) | stat: -r-xr-xr-x 519 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
use strict;
use warnings;

package MyServer;

use lib qw(./lib);
use base 'HTTP::Server::Simple::CGI';
use HTTP::Server::Simple::Static;

my $webroot = '/tmp';

sub handle_request {
    my ( $self, $cgi ) = @_;

    if ( !$self->serve_static( $cgi, $webroot ) ) {
        print "HTTP/1.0 404 Not found\r\n";
        print $cgi->header, 
        $cgi->start_html('Not found'),
        $cgi->h1('Not found'),
        $cgi->end_html;
    }
}

package main;

my $server = MyServer->new();
$server->run();