11 chdir $FindBin::Bin; # chdir to the directory of this perl script
13 $drawgraphport = $ENV{'DRAW_GRAPH_PORT'} || $drawgraphport;
15 my $d = new HTTP::Daemon LocalPort => $drawgraphport
16 or die "Error: port $drawgraphport not available.";
17 print "Please contact me at: <URL:", $d->url, ">\n";
19 $SIG{CHLD} = "IGNORE"; # do not accumulate defunct processes
21 while (my $c = $d->accept) {
23 while (my $r = $c->get_request) {
24 if ($r->method eq 'GET' && $r->url->path eq "/draw") {
25 my $http_query = $r->url->equery;
26 my $cgi = new CGI("$http_query");
27 my $url = $cgi->param('url');
28 $url = $url.'¶m.PID='.$$;
31 my $ua = LWP::UserAgent->new;
32 my $request = HTTP::Request->new(GET => "$url");
33 my $response = $ua->request($request, "prova0.$$.dot");
35 if (system("make PID=$$ > log.$$") == 0) {
36 $c->send_file_response("prova.$$.html");
38 $c->send_error(RC_INTERNAL_SERVER_ERROR);
40 } elsif ($r->method eq 'GET' && $r->url->path eq "/get_gif") {
41 my $http_query = $r->url->equery;
42 my $cgi = new CGI("$http_query");
43 my $pid = $cgi->param('pid');
44 print "Returning GIF: $pid\n";
45 $c->send_file_response("prova.$pid.gif");
46 system("make PID=$pid clean ; rm -f prova0.$pid.dot");
47 } elsif ($r->method eq 'GET' && $r->url->path eq "/help"){
48 print "Help requested!\n";
49 my $response = new HTTP::Response;
50 $response->content("Graph Drawer Version: ???");
51 $c->send_response($response);
53 $c->send_error(RC_FORBIDDEN)