It's 2015.
Python CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

What is a "Guestbook"?

When I first started using the Internet, guestbooks were popular. I'd be able to go to a website like Lissa Explains (which serves as the inspiration for this project) and leave a message with my name and a comment to the author of the website. It was a way of messaging people before you had your Facebooks and your Twitters.

For me, it was my first understanding that people all over the world could converge at the same place at the same time, to talk to each other.

What is "cgi"?

Common Gateway Interface (CGI) was what these original guestbooks were powered on. CGI was introduced in 1993 and kickstarted the move from websites just displaying static HTML (unmodified by scripts) to being able to run scripts on your web server and displaying the results on your website.

In this project; the script fetches the guestbook posts within the database, and displays them within the index.html template. I have not written the HTML for each individual post within the index template, the script does that for me. The cgi server within allows me to do this on the website itself, each time someone visits the guestbook the cgi script is activated and the posts are displayed.

In 2015 we have server-side languages like Ruby and Python, as well as client-side languages like JavaScript that can do this for us with ease without using cgi. This project is just a little homage to what the web was only a decade or so ago.

How can I use this guestbook?

NB: These instructions only cover running the guestbook locally. I'd like to write instructions on running this project on a free application hosting service like Heroku. Help with this is appreciated.

Step One: Grab the code!

You can do this either by cloning the repository if you're familiar with the command line

git clone

OR by cloning it within the graphical GitHub client for Windows or Mac

OR by downloading the .zip file directly

Step Two: Install the required packages!

I recommend working within a virtual environment when you work with this code, because it keeps all your dependencies nice and tidy and things are less likely to break.

Check the requirements.txt file for the required dependencies. The only one we are using for this application is peewee which helps to manage our guestbook database. To install peewee you will need to have [pip] ( already installed.

Within your virtual environment run the following command:

pip install -r requirements.txt

You can check to make sure the requirements are installed by running:

pip freeze

This should display peewee as the only package installed.

Step Three: Create your database!

First, check out the file. This is what we will run to create our database. The line: DATABASE = "guestbook.db" sets the name of your database.

Second, check out the dummy posts that will be created when you run this file. Unless you change it, it will create some default posts in my name. Feel free to change the details or delete these dummy posts altogether!

Thirdly, uncomment the single line of code create_tables(). This will make sure that a database is created for you with your chosen name so you can work with the guestbook.

Lastly, run the following in your terminal (within the virtual env and project directory):


If you see "Created the database!" then you have successfully created your database! You can now comment out create_tables(). If you want to re-create your database you can delete the database file, uncomment create_tables() and run python3 again.

Step Four: Run the guestbook!

Take a look at the file. It's a small file that will allow you to run the files within this project locally on your machine. I've made it so the project files will run on localhost:8000. Feel free to change the PORT within the server file.

Now, check out within the cgi-bin folder. The only thing you need to do is make sure the first line is correct. Currently it reads #!/usr/bin/env python3. This statement needs to be at the top of so cgi knows what python version it is using.

Know that must live within the cgi-bin folder or else it won't work!

Now, we're ready to run our guestbook!

In your terminal, type: python3

Navigate to http://localhost:8000/cgi-bin/ and you should see the guestbook in all it's glory! It should look something like this

With thanks to:

  • @tef for the idea to go "Web 1.0" and use cgi in the first place as well as helping me debug
  • @jennschiffer for creating so I could make sick graphics
  • Lissa Explains for still serving as inspiration, after all these years.
  • @pkqk and @tom for being patient and helpful


  • 13/01/2014: Guestbook released
  • 15/01/2014: Minor updates: Merged #14 and made all code PEP8 compliant