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

How to write a small Perl HTTP server so that I can embeded into my .exe program

Replies are listed 'Best First'.
Re: write a small Perl HTTP server
by Belgarion (Chaplain) on Jul 08, 2004 at 18:39 UTC
Re: write a small Perl HTTP server
by BrowserUk (Patriarch) on Jul 08, 2004 at 19:10 UTC

    They probably don't get much smaller than this "one-liner" from the IO::All pod.

    # A single statement web server for static files and cgis too io(":8080") ->accept("-fork") ->( sub { $_[0] < io( -x $1 ? "./$1 |" : $1) if /^GET \/(.*) / } );
    I'm not sure how well, or even if it works, but...it comes with a good pedigree.

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
      Funny stuff! That won't work for CGIs though. It doesn't set up the CGI environment variables.

      -sam

      Uh, that regexp can't be right. For one thing, the argument to GET is a URL and doesn't have to start with a slash; and there's usually an HTTP version string afterwards.
        The argument does start with a slash if your "server" is not working as a proxy, and the HTTP string comes after the space, which is also matched with the regex.
Re: write a small Perl HTTP server
by dragonchild (Archbishop) on Jul 08, 2004 at 18:20 UTC
    What operating system? What is the language for the .exe? What does it have to be able to do? Is it just serve up webpages or does it have to handle CGI requests? What about images?

    Also, what licensing requirements does your ".exe program" have? Depending, it might be able to use a number of off-the-shelf options.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested