Skip to content
Daniel Shiffman edited this page Mar 26, 2014 · 8 revisions

Terminal

To run SimpleHTTPServer, you are first going to want to become familiar using the Mac OS X terminal. The terminal provides "shell" access to your computer. You can browse directories and execute applications via text-based commands. You can find the Terminal app in Applications->Utilities->Terminal. Run it and you'll see something like.

Terminal

The blinking cursor is the "prompt", where you can execute a command. Here is a list of some common commands you'll need.

  • cd - change directory. The following, for example, will set the current path to your desktop. You'll want to replace "shiffman" with your username. cd /Users/shiffman/Desktop.
  • pwd - print working directory. This will print out the current directory.
  • ls - list the contents of the current directory.

This is barely scratching the surface of what you can do with unix commands. Adam Parrish's class also has a tutorial about using unix commands to manipulate text data. But we'll stop here, after all, we're just here to run a simple web server.

Running SimpleHTTPServer

Your job is to get terminal to point to the directory on your computer where you are storing your p5.js work. On my computer I've got a ton of examples in a directory called "The-Nature-of-Code-Examples-p5.js". So I'm going to browse to it by doing the following.

$ cd /Users/shiffman/Documents/noc/The-Nature-of-Code-Examples-p5.js

(You don't need to type the '$' I'm just using it to represent a prompt.)

Once I'm there, I can start up a web server with the following command.

$ python -m SimpleHTTPServer

I should then see:

Serving HTTP on 0.0.0.0 port 8000 ...

This means the server is up and running at localhost on port 8000. And this means I can type http://localhost:8000/ into the address of a web browser and I'll see:

localhost