Introduction to server-side scripting
These days most websites on the Internet have dynamic content. This means that the content displayed to the user has not been written directly into the HTML page but rather it has been generated by selecting information from a database that resides on the server.
This is advantageous as it means that you can create a single template page and then populate it with different information from the database depending on what page is requested.
Common Gateway Interface
The web is a client-server system. A web browser residing on your computer acts as a client which can request web pages from different web server. This can be shown as a diagram:
In order to deliver dynamic content we need to extend the abilities of the web server so that it can do more than merely send static web pages in response to client requests. The common gateway interface (CGI) provides a mechanism to do this.
When serving static web pages the server is normally asked for a file that has a .htm or .html extension e.g. http://mywebsite.com/index.html. If we wish to serve a dynamic page the extension would be different, for example .cgi or .php.
If a request comes in with one of these extensions the web server knows to pass the request to the CGI which then interprets it correctly and executes the script in the particular scripting language.
Once the script has finished executing the CGI then passes the output back to the web server to be delivered as a response to the client request. The diagram demonstrates this:
Scripting in Python
We will write our server-side scripts in Python as we can reuse most of our knowledge from writing Python programs on the desktop and it is widely used in real world for this purpose. We will also make use of MySQL to store information.
- 1. Introduction to server-side scripting
- 2. Getting ready for server-side scripting
- 3. Preparing for your first script
- 4. Create your first server-side script
- 5. Capturing and processing data
- 6. Processing the form data
- 7. Server-side scripting and databases
- 8. Adding data to a database
- 9. Displaying data from the database
- 10. More on HTML forms
- 11. Pizza Kitchen
- 12. Administration Forms
- 13. Customer Account Form
- 14. Customer Order Form
- 15. Current Orders