Search notes:

Perl module HTTP::Daemon

When the following script is started it prints the URL with which the webserver can be accessed.
Currently, the webserver allows only one path: http://localhost:*port*/myself. This will print the script itself.
#!/usr/bin/perl
use warnings;
use strict;

use HTTP::Daemon;
use HTTP::Status;

my $daemon = HTTP::Daemon->new or die;

printf ("\n\n   URL of webserver is %s, show this script with %smyself\n", $daemon->url, $daemon->url);

while (my $client_connection = $daemon->accept) { # {
    new_connection($client_connection);
} # }

sub new_connection { # {
    my $client_connection = shift;
    printf "new connection\n";
    while (my $request = $client_connection->get_request) {

      print "  request\n";
        if ($request->method eq 'GET' and $request->uri->path eq "/myself") {
            $client_connection->send_file_response($0);
        }
        else {
            $client_connection->send_error(RC_FORBIDDEN)
        }
    }
    $client_connection->close;
} # }
Github repository PerlModules, path: /HTTP/Daemon/script.pl

See also

A (simple) webserver with Perl
A (very) simple webserver using the Perl module HTTP::Server::Simple::CGI.
webserver
Perl modules.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199315, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/HTTP/Daemon/index(82): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78