Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

browser interface for local script

by blueberryCoffee (Scribe)
on Sep 29, 2006 at 09:40 UTC ( #575489=perlquestion: print w/ replies, xml ) Need Help??
blueberryCoffee has asked for the wisdom of the Perl Monks concerning the following question:

Hello all,

I have a script that runs on a user's windows machine (I don't have a choice) and uses sqlite to do reports and keep and set other info entered by the user. Athough I cannot install a traditional web server (everything must be self contained via the pp compiler) I need to have an interface to this program via a browser.

I assume this means I would need a web server that could be started/stopped by my program and interface with the sqlite database via perl cgi. Maybe I am looking in the wrong direction, but does anyone know of a perl server like this?

Thanks

Comment on browser interface for local script
Re: browser interface for local script
by Corion (Pope) on Sep 29, 2006 at 09:52 UTC

    You mean a "simple HTTP server"? Like, say, HTTP::Server::Simple ? ;-) It is quite easy to use and is quite easy to plug your code into. I gave a (German) talk on it, and thanks to a cool trick ysth taught me, the goofy English translation of the slides is also available. The Perl code suffers a bit from it, though - the use cousin pragma has fallen out of favour except in the midwest I think.

Re: browser interface for local script
by gellyfish (Monsignor) on Sep 29, 2006 at 11:55 UTC

    Is there any particular reason why you need to use a web interface rather than a more traditional GUI using, say, Tk or Win32::GUI or whatever the toolkit du jour is?

    /J\

      I don't know about you, but I've noticed that browsers are a toolkit du jour ;-)

      Need is a strong word. It is more a question of speed given time constraints and my background. Tk is great, and I used to program with it often.
Re: browser interface for local script
by qbxk (Friar) on Sep 30, 2006 at 01:22 UTC
    I tried solving this problem once. I believe it's a powerful technique that we'll begin seeing more of from not just monks.

    Here's how far I got, a module (based on HTTP::Daemon) to set up a simple framework for you to define the flow of these types of programs (since now you've gone somewhat stateless), ServerApp

    And my "sample app" thats a font browser using imagemagick for rendering: FontPreview


    It's not what you look like, when you're doin' what you’re doin'.
    It's what you’re doin' when you’re doin' what you look like you’re doin'!
         - Charles Wright & the Watts 103rd Street Rhythm Band, Express yourself
Re: browser interface for local script
by AJRod (Scribe) on Sep 30, 2006 at 06:52 UTC
    Perhaps you need XAMPP? http://portableapps.com/apps/development/xampp I'm not sure but forgive me if I misunderstood your need.
Re: browser interface for local script
by Bro. Doug (Monk) on Sep 30, 2006 at 13:44 UTC
    HTTP::Simple is an excellent solution. I would also suggest launching your browser as your script executes, saving your user the step of launching. This way, from a single click, the user can launch the HTTP server, then launch the browser from the command line ( pointed to the correct page, of course ), then run the rest of the script and fill the page.

    I bet your user would like that.

    Bro. Doug :wq
      Thanks, I used the following code:
      sub handle_request { my ($self, $cgi) = @_; my $action = $cgi->path_info(); $action =~ s|^/||; # ensure action exists or set it to default if(! $self->can($action)) { $action = "home"; } $self->$action($self, $cgi); #print $out Dumper(%ENV); }
      It is pretty neat. This makes it easy to use the MVC design pattern. I use HTML::Template to print all the pages out.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://575489]
Approved by Hue-Bond
Front-paged by derby
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-09-02 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (29 votes), past polls