Create an instant web server via Terminal command line

May 7, 2010 - 2 Comments

You can instantly create a web server from the command line by typing:

python -m SimpleHTTPServer

This will publish the current directory as a web server immediately, so if you have an index.html file that will immediately be displayed, otherwise it will just list the directory contents at your localhost IP. If you wish to specify a port you may do so by following the command with an open port number:

python -m SimpleHTTPServer 4104

This is a handy tip if you’re doing some quick web development and want to immediately check it in a browser or show it to someone else. This should work on any unix variant, FreeBSD, Linux, and of course Mac OS X included.

Related articles:

Posted by: Manish Patel in Command Line

2 Comments

» Comments RSS Feed

  1. Sandcastles says:

    If you’re behind a router you’ll need to clear the port for outside access, but this is definitely helpful for quickly showing off projects and whatnot.

    Personally I just run the web server built into Mac OS X, drop things in your Sites directory and you’re good to go.

  2. Oscar says:

    I am running OSX leopard, and I can not access the server from another computer on the same local network.
    Do you know how to open the port on OSX?

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Shared on Facebook

Shop at Amazon

Ad

OSXDaily on Facebook