Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created September 27, 2009 07:52
Show Gist options
  • Save sharifulin/194659 to your computer and use it in GitHub Desktop.
Save sharifulin/194659 to your computer and use it in GitHub Desktop.
Simple POE server
#!/usr/bin/perl
use strict;
use POE qw(Component::Server::SimpleHTTP XS::Queue::Array Loop::IO_Poll);
POE::Component::Server::SimpleHTTP->new(ALIAS => 'HTTPD', PORT => 8010, HANDLERS => [{ DIR => '/', SESSION => 'MANAGER', EVENT => 'req' }]);
POE::Session->create(inline_states => {
_start => sub { $_[KERNEL]->alias_set('MANAGER') },
req => sub {
for ($_[ARG1]) {
$_->code(200);
$_->header('content-type', 'text/plain');
$_->content($_[ARG0]->uri);
$_[KERNEL]->post('HTTPD' => 'DONE' => $_);
}
},
});
POE::Kernel->run;
__END__
Requests per second: 469.65 [#/sec] (mean)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment