--- trunk/httpd.pl 2004/05/06 12:40:11 12 +++ trunk/httpd.pl 2004/05/06 16:53:40 13 @@ -15,8 +15,6 @@ use Data::Dumper; my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die; -print "Please contact me at: url, ">\n"; - my $cgi = new CGI::Lite; my $mws = MWS->new('global.conf'); my $tt = Template->new({ @@ -26,6 +24,8 @@ }, }); +print "Web server ready at: ", $d->url, "\n"; + while ( my $c = $d->accept ) { while ( my $r = $c->get_request ) { @@ -82,6 +82,10 @@ $param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'}; } + my $tpl_var = { + param => $param + }; + # show search results # ?search=foo:bar if ($param->{'search'}) { @@ -91,28 +95,25 @@ my $results = $mws->search($param->{'search'}); my @res = $mws->fetch_all_results(); - $tt->process($tpl_file, { - query => $param->{'search'}, - results => \@res, - param => $param, - }, \$html) || die $tt->error(); + $tpl_var->{results} = \@res; + # # ?show_id=XXXXxxxx___message_id___xxxxXXXX } elsif ($param->{'show_id'}) { my $row = $mws->fetch_result_by_id($param->{'show_id'}); - $tt->process($tpl_file, { - message => $row, - }, \$html) || die $tt->error(); + $tpl_var->{message} = $row; } + $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error(); + # # send HTMLto client # my $res = HTTP::Response->new(RC_OK); - $res->header( 'Content-type' => 'text/html; charset=iso-8859-2' ); + $res->header( 'Content-type' => 'text/html; charset=UTF-8' ); $res->content($html); $c->send_response($res);