Quick, Simple Python Server

imgres.jpg

A small tip that comes in handy for local testing and development – run your own Python server in 1 terminal command.

If Python is installed* (and it is on Macs by default), go to the directory containing the files you want served, and enter the following in your terminal:

python -m SimpleHTTPServer

By default the files will be served on port 8000. In a browser, go to localhost:8000 to have some files served up. Mmmm, files.

That’s it! You have a server running locally.

If you’d like to change from the default port to another, add your preferred port number after the command, e.g.:

python -m SimpleHTTPServer 3000

Your files will be served on port 3000.

Congratulations!

 

* Check with python –version in your terminal

Learn more:

http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python

http://www.tecmint.com/python-simplehttpserver-to-create-webserver-or-serve-files-instantly/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s