Start a Web Server With One Terminal Command on OS X

I've searched for this three times this week, so I figured I'd better make sure I have a copy of it:

python -m SimpleHTTPServer 8000

Navigate to the project directory in the terminal and do that command. Then http://localhost:8000 will server up that directory (as in, it's `index.html` file).

Comments

  1. User Avatar
    Craig Morrison
    Permalink to comment#

    It can be very useful to spin up a quick server.
    php -S localhost:8000 also works in recent versions.

  2. User Avatar
    Rhys Lloyd
    Permalink to comment#

    Requires installation, but with Node:

    npm i -g http-server
    

    Once installed, you can run from any directory:

    http-server
    
    • User Avatar
      Umar
      Permalink to comment#

      I use “http-server” regularly. It is simpler and easy to remember.

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

Submit a Comment

icon-closeicon-emailicon-linkicon-menuicon-searchicon-tag