CHAPTER 15
Server-Side Scripting
“Oh, What a Tangled Web We Weave”
This chapter is the fourth part of our look at Python Internet programming. In the last
three chapters, we explored sockets and basic client-side programming interfaces such
as FTP and email. In this chapter, our main focus will be on writing server-side scripts
in Python—a type of program usually referred to as CGI scripts. Though something of
a lowest common denominator for web development today, such scripts still provide
a simple way to get started with implementing interactive websites in Python.
Server-side scripting and its derivatives are at the heart of much of the interaction that
happens on the Web. This is true both when scripting manually with CGI and when
using the higher-level frameworks that automate some of the work. Because of that,
the fundamental web model we’ll explore here in the context of CGI scripting is pre-
requisite knowledge for programming the Web well, regardless of the tools you choose
to deploy.
As we’ll see, Python is an ideal language for writing scripts to implement and customize
websites, because of both its ease of use and its library support. In the following chapter,
we will use the basics we learn in this chapter to implement a full-blown website. Here,
our goal is to understand the fundamentals of server-side scripting, before exploring
systems that deploy or build upon that basic model.
A House upon the Sand
As you read the next two chapters of this book, please keep in mind that they focus on
the fundamentals of server-side scripting and are intended only as an introduction to
programming in this domain with Python. The web domain is large and complex,
changes rapidly and constantly, and often prescribes many ways to accomplish a given
goal—some of which can vary from browser to browser and server to server.
For instance, the password encryption scheme of the next chapter may be unnecessary
under certain scenarios (with a suitable server, we could use secure HTTP instead).
Moreover, some of the HTML we’ll use here may not leverage all of that language’s
1125
Do
wnload from Wow! eBook <www.wowebook.com>