Turn any working directory into an instant file server with python
I found this tip from the threejsboilerplate makefile and I think I will be getting my mileage out of the python feature.
Simply open a terminal to your working directory and python3 -m http.server
, or wrap this up in a makefile for your own, or your collaborators ease.
Important to note, if you are using python2 the module is slightly different and you'll need to run python -m SimpleHTTPServer
instead.
Carry on,
Written by Dylan Grafmyre
Related protips
4 Responses
Great tip Dylan. The port can be modified from the 8000 default by adding the port number at the end of the command.
For Rubyists, @dallas posted this Ruby one-liner here on Coderwall:
ruby -run -e httpd . -p 8000
Now what would be really cool is a cross-platform solution to do this on any platform without requiring users lift a finger, God damn Windows for shipping with next to nothing useful.
In Windows, I use Mongoose which does the same thing. But, in Ubuntu, I like the Pythonic approach.
Since PHP 5.4, you also have it with:<br/>
php -S [host][:port] -t [docroot]</code>
Reference:
http://www.php.net/manual/pt_BR/features.commandline.webserver.php