Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

CGI Webserver In Perl?

by sectokia (Pilgrim)
on Jan 26, 2023 at 23:52 UTC ( [id://11149911]=perlquestion: print w/replies, xml ) Need Help??

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

Hi monks,

I have a large amount of legacy CGI Perl scripts, which were made to be executed by Apache modperl.

What I want to do is move to a http server inside a perl script (like AnyEvent::HTTPD) that supports calling the perl CGI scripts - and then package the entire thing as a single exe using par. This is so users can run it without having to have either apache or perl installed.

Now CGI seems fairly straight forward (content to STDIN, headers to ENV, and STDOUT is the HTTP response), but I figured someone has probably done this before? Or are there better ideas?

I am essentially doing this to execute the cgi in the httpd request callback:

{ local *STDOUT; local *STDIN; #local %ENV; #$ENV{http-cookie} = $requestCookie; open(STDIN, "<", \$requestBody); open (STDOUT, '>>', \$response); do './cgi/foobar.pl'; }

Replies are listed 'Best First'.
Re: CGI Webserver In Perl?
by markong (Pilgrim) on Jan 27, 2023 at 00:45 UTC
Re: CGI Webserver In Perl?
by hippo (Bishop) on Jan 27, 2023 at 10:51 UTC
    This is so users can run it without having to have either apache or perl installed.

    I must be missing something here because surely the simpler way to have users run it without needing them to have Apache or Perl installed would be just for you to host it somewhere on Apache with mod_perl and let the users access it directly with their web browser as normal.

    Perhaps you could explain why that isn't suitable in this case?


    🦛

      > I must be missing something here

      Hosting is expensive and that expense scales with popularity, or with attacks.

      Anything exposed to the world is a security nightmare requiring constant vigilance and updates.

      If our corporate overlords and corrupt governments don't like your content they can and will collude to destroy your entire life.

      mod_perl hosting does not exist because the perl community failed to meet the challenge posed by PHP decades ago, so you'll have to do everything yourself, which is hard.

        you'll have to do everything yourself, which is hard.

        I was meaning for the OP to do it himself in my original reply. It may be hard but it's no harder than his proposed suggestion and (for me anyway) should be much easier. YMMV.


        🦛

Re: CGI Webserver In Perl? (apacheet)
by Anonymous Monk on Jan 27, 2023 at 12:50 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11149911]
Approved by kcott
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found