Last Updated: February 25, 2016
·
708
· thorsummoner

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,

4 Responses
Add your response

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
over 1 year ago ·

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.

over 1 year ago ·

In Windows, I use Mongoose which does the same thing. But, in Ubuntu, I like the Pythonic approach.

over 1 year ago ·

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

over 1 year ago ·