Avatar of Mark
Mark

asked on 

Put query string from URL request - PERL HTTP Daemon

I want to be able to call for example:

127.0.0.1:8000/?abc=123

And get the value of 'abc' printed to the console..



##!/usr/bin/perl

use HTTP::Daemon;
use Data::Dumper;

my $d = HTTP::Daemon->new(
    LocalPort => 8000
) || die;

while (my $c = $d->accept) {
    while (my $request = $c->get_request) {
		
print $request->url->path();

        my $response = HTTP::Response->new( 200, 'OK');
        $response->header('Content-Type' => 'text/html'),
        $response->content("Ack");
        $c->send_response($response);
		$c->close;
		exit;
    }
}

Open in new window

Perl

Avatar of undefined
Last Comment
Mark

8/22/2022 - Mon