Getting ready for server-side scripting

By following the instructions below you will create a suitable environment on your computer to learn about server-side scripting with Python.

If you are attending a taught session then the instructions to set-up and access the server will differ from those given below. In this case your instructor will be able to tell how to access the server.

Localhost Server

Normally server-side scripts form part of a dynamic website which is stored on some remote web server. You would edit your pages on your computer and then upload them to the server via a FTP program.

You would access your files via a web browser by typing in some URL:

  • e.g.

This is pretty inconvenient whilst testing your scripts or when you are learning about server-side scripting. Thankfully your can simulate a web server locally by installing additional software on your computer.

Installing XAMPP

We will be using the XAMPP suite of software to simulate a web server locally on your computer. There are other ways of setting up such a server but XAMPP provides a nice balance between functionality and ease of use.

You will need to download and install the appropriate XAMPP installation package for your Operating System:

Setting the Python path (Windows only)

If you are using Windows you will need to add Python to the system path. If you are on Mac OS X (or another Operating System) you can skip this step.

Adding Python to the System Path

The video below demonstrates how to do this on Windows 7:

Installing the MySQL Connector

The majority of the exercises in this section are going to involve communicating with a MySQL database from Python. You will need to download and install the MySQL connector so that they can communicate with each other.

Follow the steps below to do this:

  1. Download the MySQL Connector
  2. Ensure that you have added Python to your system path (Windows only - see above section)
  3. Unzip the downloaded MySQL Connector archive
  4. Follow the instructions given the the video below for your OS:

Installing the Python MySQL Connector

The video below demonstrates how to do this on Mac OS X:

The video below demonstrates how to do this on Windows 7:

HTML Editor

The last item you will need is a HTML editor to create and edit HTML documents. Whilst IDLE or a simple text editor such as Notepad can be used for HTML editing, they lack the features of proper HTML editors. A proper HTML editor will highlight your code and make it easier to spot mistakes.

There are many HTML editors available including:

Ready, Set, Go

Remember that XAMPP is providing a local web server, if you want you scripts to be available on the Internet you will have to host them with a a service provider that supports Python as a scripting language.

Now that the environment has been set-up it is time to write your first Python server-side script.