[Tutor] how to add python code to a webpage

Alan G alan.gauld at freenet.co.uk
Mon Jul 18 13:09:40 CEST 2005


> i want to create a simple page which has a form
> and takes in persons date of birth and give out exact age.

CGI would be the normal route but...

> how do i add python codeto an html page.

You can use an ASP style approach if you install winall and have WSH 
enabled
on Windows, but it will only work in IE, not Mozilla based browsers.

Another way of doing it is to use Zope, but thats way overkill for 
your needs.

> i don't have any dreamweaver or frontpage.

Thats OK, you can write html in Notepad if necessary.

Take a look at the 'Getting Started' page in my tutor,
there it talks about setting up JavaScript and VBScript.

You would do the same but use

<script language="python">
   # your code here
</script>

instead of the other languages.

> some freinds advised me to create this isnce i am learning 
> programming python..

Writing web pages is only one kind of programming (And not really a 
very fun
kind IMHO!). Python can do many other types of programs including GUI 
based
applications too. But either CGI or Client Side Scripting (as the 
above technique
is called) can be done in Python.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list