The best way to test your Three.js applications, or any JavaScript application for that matter, is to run it on a local web server. This way, you have the best representation of how your users will eventually see your Three.js visualization. In this chapter, we will show you three different ways in which you can run a web server locally. The three different ways to set up a local web server are:
npm
command to install a simple web servernpm
command or Python, you can also use Mongoose, which is a simple portable web server, that runs on OS X and WindowsThis recipe will focus on the Python-based approach (the first bullet point).
If you've got Python installed, you can very easily run a simple web server. You will first need to check whether you've got Python installed. The easiest way to do this is just type in python
on a console and hit enter. If you see an output as follows, you are ready to begin:
> python Python 2.7.3 (default, Apr 10 2013, 05:09:49) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
> python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000...
If you don't have Python installed, take a look at one of the following two recipes for alternative options.
52.14.17.40