Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

HTML as GUI for Perl program

by tale103108 (Novice)
on Jan 04, 2013 at 22:11 UTC ( #1011726=perlquestion: print w/ replies, xml ) Need Help??
tale103108 has asked for the wisdom of the Perl Monks concerning the following question:

I would like to use my browser as a GUI for a Perl script, passing the HTML form data to my Perl script. Is this possible without the inclusion of a web server or container to handle the HTTP POST? If so, an example .html and .pl file would be greatly appreciated. Also, please show (if any) distinctions between running your example on Windows 7 and Linux. Thanks oh wise monks of the Perl monastery

Comment on HTML as GUI for Perl program
Re: HTML as GUI for Perl program
by SuicideJunkie (Priest) on Jan 04, 2013 at 22:17 UTC

    If it doesn't have to be interactive, then you can just have the perl script write out an HTML file before it exits.

    If you want it to be interactive, then you have to be listening for when the browser makes a request. The listener doesn't have to be complicated, and it could be done with pure perl, but it does have to be there.

Re: HTML as GUI for Perl program
by LanX (Canon) on Jan 04, 2013 at 22:17 UTC
    > without the inclusion of a web server or container

    depends on your definition of "webserver", there are plenty of examples where a simple script builds a HTTP connection via a dedicated port, i.e. w/o a "standard webserver" like apache.

    Best known example are pod servers.

    EDIT: The problem is rather to automatically launch a browser/ open a new tab when you start your script . Otherwise the user hast to connect manually to a dedicated port.

    Cheers Rolf

    UPDATE:

    typical usecase

    lanx@nc10-ubuntu:~$ podwebserver I am process 8706 = perl Pod::Webserver v3.05 Indexing all of @INC -- this might take a minute. ... Done scanning @INC You can now open your browser to http://localhost:8020/
Re: HTML as GUI for Perl program
by davido (Archbishop) on Jan 04, 2013 at 22:49 UTC

    It's a whole lot easier if you relax the "no server" requirement. Maybe easier than you suppose. You could build the application's business logic, thinly wrap it in a Mojolicious::Lite interface, and use Mojolicious's built-in server to serve it on any port of your choosing. Don't open the port to the outside world at your firewall, and restrict (using a route bridge, or "under" in Mojolicious::Lite) the client's IP to just the local machine if outside access is of concern.

    Done right, at the command line you would type, "./mymojo_app.pl daemon" to start it up on port 3000, for example.


    Dave

Re: HTML as GUI for Perl program
by Anonymous Monk on Jan 04, 2013 at 23:35 UTC

    Is this possible without the inclusion of a web server or container to handle the HTTP POST?

    No, magic is impossible. HTTP (POST or anything) requires HTTP server, always.

      I don't have to literally do a HTTP POST. All I want is a way to use my browser as a GUI front-end to accept my input to a subsequent Perl script that is then called (when the user hits 'Submit' e.g.) and does its thing. I just was hoping that it would be easier to build a GUI front-end using my browser as opposed to say Tk. And the browser/GUI would make my application friendly to use -- as opposed to command-line arguments or prompts.

        In theory you could try XUL. See also Perl and XUL app for a discussion.

        Practically it's far from being "easier than TK" and if you wanna use "my browser" you need to install "your browser" on the users machine.

        So you can't take any technology for granted when using HTML, with the exception of interacting with HTTP-requests which consequently makes your script a local server.

        Additionally you would need an extra layer of JS for mimicking a dynamic GUI like TK is.

        And all of this won't change the fact that HTTP has no mean to make the frontend react on the server pushing actions. The browser needs to poll for any dynamic changes like e.g progress infos.

        Cheers Rolf

        I don't have to literally do a HTTP POST....

        :) your question wasn't unclear :) browsers are all about TCP/IP, HTTP and them

Re: HTML as GUI for Perl program
by Anonymous Monk on Jan 04, 2013 at 23:36 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011726]
Approved by Perlbotics
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-07-28 23:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (210 votes), past polls