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
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/69222/cs-ava.png)
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
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/94005/407d4b68afe5b3a71e84a1a3d5811cff.png)
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.
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/26058/vraa.jpeg)
In Windows, I use Mongoose which does the same thing. But, in Ubuntu, I like the Pythonic approach.
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/8244/12488f9650f5abe0291e36e48022eca9.png)
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