Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This is just a quick hack on the example that comes with HTTP::Daemon to serve your local perl documentation out with http. I rather like the way ActiveState perl on windows formats the docs, so I did this to read them when I'm working on my linux box.

I realize this is not secure, it is in no way meant to be, it only binds to localhost on port 83 because of this. Open it up to the world at your own discretion. Browsing to http://localhost:83 will give error 501/505 to avoid uninvited guests, you must request http://localhost:83/index.html to load the page.
#!/usr/bin/perl use strict; use warnings; use HTTP::Daemon; use HTTP::Status; my $perldocs = 'c:/Perl/html/'; my $n = "\n"; my $d = HTTP::Daemon->new(LocalAddr=>'localhost',LocalPort=>83) || die +; print "Listening on: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { print $r->method." ".$r->url->path.$n; if ($r->method eq 'GET') { -e $perldocs.$r->url->path ? $c->send_file_response($perldocs.$r->url->path) : $c->send_error(RC_NOT_FOUND); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }
I was inspired to post this after seeing perldoc.cgi this morning. Anyone care to merge them?

In reply to Serve local perl docs with HTTP::Daemon by elwarren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found