| 1 |
#!/opt/perl/bin/perl |
| 2 |
use common::sense; |
| 3 |
use AnyEvent; |
| 4 |
use AnyEvent::HTTPD; |
| 5 |
|
| 6 |
my $cvar = AnyEvent->condvar; |
| 7 |
|
| 8 |
my $httpd = AnyEvent::HTTPD->new (port => 19090); |
| 9 |
|
| 10 |
$httpd->reg_cb ( |
| 11 |
'' => sub { |
| 12 |
my ($httpd, $req) = @_; |
| 13 |
$req->respond ({ content => ['text/html', <<'CONT']}); |
| 14 |
<html><body><h1>Hello World!</h1> |
| 15 |
<a href="/test">another test page</a> |
| 16 |
</body></html> |
| 17 |
CONT |
| 18 |
}, |
| 19 |
'/test' => sub { |
| 20 |
my ($httpd, $req) = @_; |
| 21 |
$httpd->stop_request; |
| 22 |
|
| 23 |
$req->respond ({ content => ['text/html', <<'CONT']}); |
| 24 |
<html><body><h1>Test page</h1> |
| 25 |
<a href="/">Back to the main page</a> |
| 26 |
</body></html> |
| 27 |
CONT |
| 28 |
}, |
| 29 |
); |
| 30 |
|
| 31 |
$cvar->wait; |