On Sat, May 05, 2012 at 05:32:54AM +0100, Stroller wrote
> Consider this installation-free alternative:
> http://www.google.co.uk/searchq=one+line+python+web+server
This. Here's a Gentoo-specific script, which I saved as "~/bin/webd"
that handles Python 2 and 3...
===================================================
#!/bin/bash
cd ${1}
current_python=`eselect python show`
if [ "${current_python:0:7}" == "python2" ]; then
python -m SimpleHTTPServer
elif [ "${current_python:0:7}" == "python3" ]; then
python -m http.server 8000
fi
===================================================
If it's called as simply "webd", it serves up my home directory. If
it's called as "webd /usr/portage/distfiles" it allows access to my
distfiles directory. Note that the user that launches webd has to have
at least read access to the directories to be served.
--
Walter Dnes <[email protected]>