Creating Webpages with SWI-Prolog and PWP: An Introduction

Although Prolog is not often associated with web application development, it provides several libraries that make it an excellent tool for creating web applications. Using Prolog, you can deploy a basic server and create dynamic data-driven websites with forms, sessions, authentication, and more.

For these tutorials, I will be focusing on PWP (Prolog Well Formed Pages). This method of server-side scripting that makes it possible to create Prolog-driven webpages using valid well-formed XML. It allows you to create templates using HTML, with just a few added attributes. This approach does not support mixing Prolog and PWP within the same file, and encourages creators to keep their presentation layer separated from logic and data.

Getting Started

Before getting started with creating Prolog-driven websites, you will need to install SWI-Prolog (from source to have access to the required libraries). There are different ways to accomplish this, depending on your environment. The SWI-Prolog website has some documentation on how to build Prolog from source on several different platforms. You can also set up Prolog on a Raspberry Pi.

Tutorials

  1. Prolog on a Raspberry Pi
  2. Quick & Dirty Intro to Prolog
  3. Starting a Server
  4. Handling Assets
  5. Displaying Lists – Coming Soon
  6. Bootstrap Example – Coming Soon
  7. Creating a Template – Coming Soon
  8. Bonus: Hosting a SWI-Prolog site on Cloud9 – Coming Soon

More Coming Soon…

Checkout the Code

Example code for all tutorials is available on Github here.

Further Reading