Python and HTML frames

Gerson Kurz gerson.kurz at t-online.de
Sat Jun 1 16:15:19 CEST 2002


I'm assuming you're writing a CGI, so:

#! /usr/bin/python
import cgi, sys, os

print "Content-type: text/html\n"

def GenerateMainFrame():
    print """<html><frameset cols="529,*">
<frame name="Inhalt" target="Hauptframe"
src="/cgi-bin/frames.py?cmd=frame1">
<frame name="Hauptframe" src="/cgi-bin/frames.py?cmd=frame2">
<noframes><body><p>blablabla</p>
</body></noframes></frameset></html>"""

def GenerateFrame1():
    print "<html><body><h1>TODO: add code for frame
#1</h1></body></html>"

def GenerateFrame2():
    print "<html><body><h1>TODO: add code for frame
#2</h1></body></html>"

page, form = None, cgi.FieldStorage()
if form.has_key('cmd'):
    page = form['cmd'].value

if page == "frame1":
    GenerateFrame1()
elif page == "frame2":
    GenerateFrame2()
else:
    GenerateMainFrame()




More information about the Python-list mailing list