blueberryCoffee has asked for the wisdom of the Perl Monks concerning the following question:

I have an app that uses HTTP::SERVER::Simple, Sqlite and HTML::Template to provide an html based application for a user. I have everything working great except that I have to hard code the image paths because the server does not seem to have a root.

I realize I may be missing something elemental here, but anyone have an idea of how I could set things up so that an image like "c:/theapp/images/top.jpg" can be referenced in html as "/images/top.jpg".

Thanks in advance
  • Comment on setting server root HTTP::SERVER::Simple

Replies are listed 'Best First'.
Re: setting server root HTTP::SERVER::Simple
by Corion (Patriarch) on Oct 09, 2006 at 17:39 UTC
      bless you, that is just what I needed. I now have this working
      sub handle_request { my ($self, $cgi) = @_; # is this an static request or dynamic # actions do not have a period as they are # functions of the webserver rather than files if($cgi->path_info() =~ /\./) { $self->serve_static($cgi,"c:\\appdir\\html"); } else { # ensure action exists or set it to default my $action = $cgi->path_info(); $action =~ s|^/||; if(! $self->can($action)) { $action = "home"; } $self->$action($cgi); } }
      Having dynamic requestes be functions of the web server is probably not the best way to go about this, but it is working. Not sure what the best way of doing it is.