Web Server with HTTP::Daemon, HTML not rendering
I figure out a way to create a quick web server in perl

    #!/usr/bin/env perl -s -wl
    
    use strict;
    
    use HTTP::Daemon;
    use HTTP::Headers;
    use HTTP::Response;
    
    sub help {
      print "$0 -port=<port-number>";
    }
    
    our $port;
    our $addr = "localhost";
    
    $port = 9000 unless defined $port;
    
    my $server = HTTP::Daemon->new(
        LocalAddr => $addr,
        LocalPort => $port,
        Listen => 1,
        Reuse => 1,
    );
    
    die "$0: Could not setup server" unless $server;
    print "$0: http://$addr:$port Accepting clients";
    
    while ( my $client = $server->accept() ) {
        print "$0: Client recieved";
        
        $client->autoflush(1);
        
        my $request = $client->get_request;
        
        print "$0: Client's Request Recieved";
        print "$0: Request: " . $request->method;
        
        if ( $request->method eq 'GET' ) {
            my $header = HTTP::Headers->new;
            $header->date( time );
            $header->server("$0");
            $header->content_type( 'text/html' );
            
            my $content = "<!doctype html><html><head><title>Hello World</title></head><body><h1>Hello World!</h1></body></html>";
            my $response = HTTP::Response->new( 200 );
            $response->content( $content );
            $response->header( "Content-Type" => "text/html" );
    
            $client->send_response( $response );
        }
        
        print "$0: Closed";
        
        $client->close;
        undef( $client );
    }

but for some reason, every time I access `localhost:9000` it displays part of the HTTP Header - date, server, content-length and content-type - and the content - a simple html page, I hope. Why does it not render correctly.

Just a side note, I have something similar done in python and the html code does work.
Web Server with HTTP::Daemon, HTML not rendering
===

I figure out a way to create a quick web server in perl

    #!/usr/bin/env perl -s -wl
    
    use strict;
    
    use HTTP::Daemon;
    use HTTP::Headers;
    use HTTP::Response;
    
    sub help {
      print "$0 -port=<port-number>";
    }
    
    our $port;
    our $addr = "localhost";
    
    $port = 9000 unless defined $port;
    
    my $server = HTTP::Daemon->new(
        LocalAddr => $addr,
        LocalPort => $port,
        Listen => 1,
        Reuse => 1,
    );
    
    die "$0: Could not setup server" unless $server;
    print "$0: http://$addr:$port Accepting clients";
    
    while ( my $client = $server->accept() ) {
        print "$0: Client recieved";
        
        $client->autoflush(1);
        
        my $request = $client->get_request;
        
        print "$0: Client's Request Recieved";
        print "$0: Request: " . $request->method;
        
        if ( $request->method eq 'GET' ) {
            my $header = HTTP::Headers->new;
            $header->date( time );
            $header->server("$0");
            $header->content_type( 'text/html' );
            
            my $content = "<!doctype html><html><head><title>Hello World</title></head><body><h1>Hello World!</h1></body></html>";
            my $response = HTTP::Response->new( 200 );
            $response->content( $content );
            $response->header( "Content-Type" => "text/html" );
    
            $client->send_response( $response );
        }
        
        print "$0: Closed";
        
        $client->close;
        undef( $client );
    }

but for some reason, every time I access `localhost:9000` it displays part of the HTTP Header - date, server, content-length and content-type - and the content - a simple html page, I hope. Why does it not render correctly.

Just a side note, I have something similar done in python and the html code does work.