in reply to need some HTTP::Server::Simple::CGI example
When I wrote CGI::Application::Server I used the source code from HTTP::Server::Simple::Kwiki as my guide, it helped quite a lot.
Of course it all depends on how robust or complex you want your self contained server to be. A simple server with little or no error checking is really easy, a full fledged server which is robust in the face of bad HTTP input is much more difficult.
For instance, here is a simple (5 line) server "framework" which I have used in the past for quick stuff.
The usage is as simple as:package Foo::Server; use HTTP::Server::Simple::CGI; our @ISA = qw(HTTP::Server::Simple::CGI); our $CALLBACK; sub handle_request { $CALLBACK->(@_) }
$Foo::Server::CALLBACK = sub { my ($server, $cgi) = @_; print "Hello " . ($cgi->param('name') || 'World') }; Foo::Server->new()->run();
|
|---|