This post originated from an RSS feed registered with Python Buzz
by Kevin Altis.
Original Post: Instant Web Server
Feed Title: Kevin Altis' Weblog
Feed URL: http://altis.pycs.net/rss.xml
Feed Description: Python, Open Source, PythonCard
When I need to serve up a few files for friends or try out some CGIs, XML-RPC, etc. I generally just fire up the PythonCard webserver sample. However, I find the following single line at a command prompt to be quite appealing for an instant web server.
python -c '__import__("SimpleHTTPServer").test()'
It works on any OS where you have Python installed and since you can cd (change directory) to the dir you want to serve files from before running the command you don't have to mess with config files or moving files before serving them up. If you alias the command or make a batch file you won't have to remember the whole line. Here's an example run on my Mac.