When developing websites and web maps, there are two main locations you are going to be working in. The first is your web server. Your web server is the computer that is broadcasting, or 'serving', your web page and it's content to the internet. This is also known as the 'production server', your web host, or your remote host. On your production server, you have your working website that is accessible to all on the internet.
The second is your local machine, such as your laptop or desktop computer. You will rarely want to actively edit files that are on your web server, so it is recommended that you do this on your own machine, without broadcasting all of your changes to the internet. This is commonly called your 'development server', or your localhost. However, there is a problem, your personal computer is not a server. If we want to develop and test run our sites, we have run a web server locally on our machine, visible only to us.
Web Servers are complicated, and a full explanation of how they work is beyond the scope of this tutorial, but creating a localhost server on our computer that mimics the capabilities of a web server can be quite easy, and can be very important for testing and development.There are a handful of good options for setting up servers on which you can develop and build sites locally before pushing them live to the web. This tutorial will look at two options, a very simple solution using Python that allows for static HTML sites, and using XAMPP, a nice local development environment software that supports Apache, MySQL, PHP, and Perl.
If you need a quick web server that can process HTTP requests but don't want to install XAMPP or another software, then Python can help. Python comes with a simple built in HTTP server that can run static webpages. With the help of this little HTTP server you can turn any directory in your system into your web server directory. The only thing you need to have installed is Python.
Open a command line to see if Python is installed.
python –V. Hit enter.
python –V. Hit enter.
Command Prompt (Windows) and Terminal (Mac) are both commonly referred to synonymously, interchangeably, or simply as “the command line”. It is the way you can access your machine by typing commands to tell it what to do.
Your command line will either return a Python version, or say Python is not recognized. If it returns a version, you have Python installed, if it is not recognized, you need to install Python. In the following screenshot, you can see I have Python Version 2.7.5 installed on my machine.
To install Python, use the following guides.
Once installed, check the version again to make sure it is working.
With Python working and installed, running a simple local server is now the matter of navigating to the location of our web folder, then running a single line command that will start our local server in this folder. In the following instructions, assume that I would like to share the directory
/documents/mywebsite and my IP address is
Open up command line (Terminal on Mac, Command Prompt on Windows). The
cd command changes our directory. Type
cd followed by the path to our local web folder.
$ cd /documents/mywebsite
To see the listing of files your current location, once you have changed your directory, type
dir on Windows, or
ls on Mac.
Once in your website folder, type the following command
$ python -m SimpleHTTPServer
That's it! Now your http server will start in port 8000. You will get the message:
$ cd /document/mywebsite $ python -m SimpleHTTPServer Serving HTTP on 0.0.0.0 port 8000 ...
This can now run in the background, you don't need to do anything else.
Now open a browser and type the following address:
You can also access it via:
If the directory has a file named index.html, that file will be served as the initial file. If there is no index.html, then the files in the directory will be listed.
$ python -m SimpleHTTPServer 8080
Now open a browser and access your site at:
Modify and change folders in web folder, save and then refresh your page. Your page will appear as it would if it were live on the internet.
When done working on your web site, stop your server using CTRL-C (Mac/Windows). This will end the local server instance.
The Python SimpleHTTPServer is a quick and easy solution for getting a localhost server running that you can use locally develop your page before pushing it to production. It will work for basic static website purposes. If you need more advanced options, such as the ability to interface with MySQL or PHP, I suggest using XAMPP.
Happy Web Developing!
Go Back to DUSPviz Tutorials Page