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

here's the thing, i have a dynamic dns (a static hostname pointing to my computer's ip, which changes every time i disconnect from the internet), that i have an ftp server running off of, and i want to know what would be involved in just a simple little script running in the background to listen for http requests and return a prewritten html page (along the lines of "my ftp server...for more info, email me at email"). thats pretty much all i need right now...does any such thing exist, and if not, how do i go about writing such a simple thing?

Replies are listed 'Best First'.
Re: quick and dirty http page server
by edan (Curate) on Jan 15, 2004 at 06:38 UTC

    You might want to look at the HTTP::Daemon module, which comes with LWP, if I'm not mistaken.

    --
    3dan

Re: quick and dirty http page server
by Corion (Patriarch) on Jan 15, 2004 at 07:01 UTC

    I did once write such a minimal HTTP server (although it can serve more than one page) here. It uses HTTP::Daemon to do all the heavy lifting, and serves static files.

    Because of the simplicity, it dosen't support authentification, CGI, logfiles or anything interesting.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: quick and dirty http page server
by CountZero (Bishop) on Jan 15, 2004 at 06:59 UTC
    I would probably go for installing a small real webserver rather than cobble something up myself.

    It would have the benefit of being easy to extend (if ever you need more than one page) and have some proven track record/history regarding security etc. ... . It would log who visited me, could redirect to the FTP-site, ...

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: quick and dirty http page server
by Anonymous Monk on Jan 15, 2004 at 07:09 UTC
    hmm...does anyone have any suggestions on a good small http server for personal use?
      What operating system are you running? Linux? Solaris? Windows?

      Linux
      The apache web server is probably already installed (and enabled).

      Windows
      Goto the apache website and download the latest stable apache binary release package. Installation is pretty simple. And you can always ask questions here if you get stuck.

      Solaris
      At home? I want one too. ;-)

        FYI, if you happen to be running Apple's OS X, which is BSD under the hood, apache comes with it, installed. It's just not turned on by default, which is a good thing.

        --
        tbone1
        And remember, if he succeeds, so what.
        - Chick McGee

        Wow, the selection of Operating Systems sure has dwindled since last I checked...

        --
        3dan