#!perl6 use v6; my $port = @ARGS[0] // 8080; my $sock = listen($port); say "Please connect to:"; say " http://localhost:$port/"; while (1) { my $hdl = $sock.accept; my $thr = async { while (=$hdl ~~ rx:perl5/\S/) { 1 }; $hdl.say("HTTP/1.0 200 OK"); $hdl.say("Content-Type: text/html; charset=UTF-8"); $hdl.say("Server: Pugs driven HTTP/1.0 server"); $hdl.say(qq[ Hello from Pugs!

Hello from Pugs on $*OS!

We are now { time() } seconds since the Y2K epoch.

Your random number of the day is: { int(rand(10)) }

]); $hdl.close; }; say "Created thread: $thr"; }