Teach Windows build and installer about new _symtable module/DLL.
[python/dscho.git] / Mac / Demo / cgi / realcgitest.py
blobe51cb9782079ae07e84b7f6885581236f7cd11f3
1 """cgitest - A minimal CGI applet. Echos parameters back to the client.
2 """
4 from MiniAEFrame import AEServer, MiniApplication
5 import MacOS
7 debug=1
9 class CGITest(AEServer, MiniApplication):
11 def __init__(self):
12 MiniApplication.__init__(self)
13 AEServer.__init__(self)
14 self.installaehandler('aevt', 'oapp', self.open_app)
15 self.installaehandler('aevt', 'quit', self.quit)
16 self.installaehandler('WWW\275', 'sdoc', self.cgihandler)
17 if debug:
18 self.installaehandler('****', '****', self.otherhandler)
19 oldparams = MacOS.SchedParams(0, 0)
20 self.mainloop()
21 apply(MacOS.SchedParams, oldparams)
23 def quit(self, **args):
24 self.quitting = 1
26 def open_app(self, **args):
27 pass
29 def otherhandler(self, *args, **kwargs):
30 print 'Unknown AppleEvent'
31 print 'args', args
32 print 'kwargs', kwargs
34 def cgihandler(self, pathargs, **args):
35 if debug:
36 print 'CGI request', pathargs, args
37 rv = """HTTP/1.0 200 OK
38 Server: Unknown; python-cgi-script
39 MIME-Version: 1.0
40 Content-type: text/html
42 <title>Python CGI-script results</title>
43 <h1>Python CGI-script results</h1>
44 <hr>
45 """
46 rv = rv+'<br><b>Direct object:</b> %s\n'%pathargs
48 for key in args.keys():
49 if key[0] != '_':
50 rv = rv + '<br><b>%s:</b> %s\n'%(key, args[key])
51 rv = rv +'<hr>\nSee you next time!\n'
53 # Note: if you want to quit after each request enable the line
54 # self.quitting = 1
56 return rv
58 if __name__ == '__main__':
59 CGITest()