A common need is to bring up a web server ad-hoc to serve out some files via HTTP. Most of the time I am using this trick when I want to serve a local directly quickly via HTTP without setting up anything for it.
Python has a module http.server which can be started also from the command line:
python -m http.server 8000 --bind 127.0.0.1
That's all it needs to serve up the current directory via HTTP. If the parameter --bind is omitted, it will bind to all interfaces.
- Quickly sharing something on a local network. Be careful though, better understand what is on your network and which directory you are serving up.
You will have to use a different command line if you are only having Python 2 available:
python -m SimpleHTTPServer 8000
Commentscomments powered by Disqus