[Tutor] Creating your first CGI-script

Sean 'Shaleh' Perry shalehperry@attbi.com
Fri Jun 6 21:19:01 2003


On Thursday 05 June 2003 08:52, Ole Jensen wrote:
> First of all, I have no experince in web programming, but my plans are to
> get into that sooner rather than later. So if my assumptions below are
> hillariously wrong feel free to correct me before what I think I know
> sticks with me :-).
>

there's a lot in here, let's see if we can shed some light on a few things 
....

> I know there is more to web programming other than CGI, I just don't know
> what (I have heard of SQL (databases?), XML (The future of the web, maybe?
> (XHTML)), but I'm not sure that this has anything directly to do with
> Python.

In the beginning (aka 8+ years ago) there was basically two ways to write 
non-static web sites -- Server Side Includes and CGI.

In Server Side Includes (SSI) you put some code in a web page and when the web 
server sent the page to the user it also executed the includes.  This is how 
people used to handle "Last modified on ...." as well as a standard header / 
footer for all of their pages.

CGI was the real work horse.  You can write them in any language that reads 
from standard in and writes to standard out.  This is how EVERYONE did 
websites before Javascript, Java, PHP, ASP, etc.  These days it is largely 
replaced by the aforementioned technologies.

As for SQL, that is the standard way to handle date storage and retrieval.  We 
programmers like it when different parts of a problem are handled locally.
For example, you could put stock information in a database.  Now when your 
website wants to show a user a ticker symbol you just query with SQL.  But, 
you could also write a nifty Windows GUI for your employees too that also 
used SQL.  You see?  Lots of readers, one central repository.  All of them 
running different operating systems, software, languages, etc.

As for XML, that seems to be "the next big thing" (tm).  Some people love it, 
some of us dislike it.  If you learn how HTML works you also understand the 
basics of XML.  Sure there is more to it, but you can learn as you go.

> So what I'm hoping you can help me with; is what I need to make CGI
> scripts. I guess it's possible to create and test CGI locally (i.e. without
> uploading it to the net). Then again does it require some server software
> to run cgi scripts (or rather test them). I assume (from reading this tutor
> mail)that the necesary software is included in the Python download. Anyway
> if not, I'm using Win XP and hoping you can recommend some server software
> to use to test my CGI-scripts. Also, my current homepage server (through my
> ISP) does not support CGI, so if you now of any free (as in no-cost) web
> hosters that support Python I'ld be happy to know.

As mentioned above, CGIs simply read input and write output, the web server 
handles the network connections.  So you can easily test CGIs by running them 
and sending in the data (once you learn the right data to send).  There are 
lots and lots of tutorials, books, etc on this.  Any used book store should 
have plenty of CGI books.

To really test the CGI you need a web server that supports CGIs.  My guess is 
IIS does.  You can also run apache on windows.

> I've been looking at
> www.freezope.org but they don't support cgi so I'm not really sure if thats
> what would suit my needs, BTW what can you use their service to create?
>

Zope is another one of those technologies that helped kill CGI (-: