← Previous Section Next Section →

4.1 Running X3DOM Applications with a Simple Python Server

A very quick and convenient method to test your Web applications with a simple server is to use python's HTTP server module. This just requires that you have a python interpreter installed. You can download one from python.org. You can do a lot of useful things with python, and it also comes with a module that offers basic HTTP server functionality. To use it, open a command line window (no matter which operating system you are using) and navigate to the folder where your X3DOM application is located. If you are using a Python 2.X version, you can then launch the SimpleHTTP server module as a standalone application from the command line:

    python -m SimpleHTTPServer

If you are running a Python 3.x version, the command looks slightly different:

    python3 -m http.server

By default, the server is using port 8000. If you want to change this behavior, you can specify another port number by simply appending it to the command. For Python 2.x, using port 8023 will, for example, look like this:

    python -m SimpleHTTPServer 8023

You can then reach the server by opening your browser and navigating to localhost and by using the port you specified, for example:


If you have placed an index.html file inside the directory from which you started the python server, this file should now be displayed inside your browser. Otherwise, you will see a listing of the files in the directory, and you can browse through the files to launch your website.