1 |
On Sat, May 05, 2012 at 05:32:54AM +0100, Stroller wrote |
2 |
|
3 |
> Consider this installation-free alternative: |
4 |
> http://www.google.co.uk/searchq=one+line+python+web+server |
5 |
|
6 |
This. Here's a Gentoo-specific script, which I saved as "~/bin/webd" |
7 |
that handles Python 2 and 3... |
8 |
|
9 |
=================================================== |
10 |
#!/bin/bash |
11 |
cd ${1} |
12 |
current_python=`eselect python show` |
13 |
if [ "${current_python:0:7}" == "python2" ]; then |
14 |
python -m SimpleHTTPServer |
15 |
elif [ "${current_python:0:7}" == "python3" ]; then |
16 |
python -m http.server 8000 |
17 |
fi |
18 |
=================================================== |
19 |
|
20 |
If it's called as simply "webd", it serves up my home directory. If |
21 |
it's called as "webd /usr/portage/distfiles" it allows access to my |
22 |
distfiles directory. Note that the user that launches webd has to have |
23 |
at least read access to the directories to be served. |
24 |
|
25 |
-- |
26 |
Walter Dnes <waltdnes@××××××××.org> |