#!/usr/bin/env perl6

use HTTP::Server::Tiny;

my $port = 8080;

# Only listen for connections from the local host
# if you want this to be accessible from another
# host then change this to '0.0.0.0'
my $host = '127.0.0.1'; 

HTTP::Server::Tiny.new(:$host , :$port).run(sub ($env) {
    my $channel = Channel.new;
    start {
        for 1..100 {
            $channel.send(($_ ~ "\n").Str.encode('utf-8'));
        }
        $channel.close;
     };
     return 200, ['Content-Type' => 'text/plain'], $channel
});

# vim: ft=perl6
