1 """cgitest - A minimal CGI applet. Echos parameters back to the client.
4 from MiniAEFrame
import AEServer
, MiniApplication
9 class CGITest(AEServer
, MiniApplication
):
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
)
18 self
.installaehandler('****', '****', self
.otherhandler
)
19 oldparams
= MacOS
.SchedParams(0, 0)
21 apply(MacOS
.SchedParams
, oldparams
)
23 def quit(self
, **args
):
26 def open_app(self
, **args
):
29 def otherhandler(self
, *args
, **kwargs
):
30 print 'Unknown AppleEvent'
32 print 'kwargs', kwargs
34 def cgihandler(self
, pathargs
, **args
):
36 print 'CGI request', pathargs
, args
37 rv
= """HTTP/1.0 200 OK
38 Server: Unknown; python-cgi-script
40 Content-type: text/html
42 <title>Python CGI-script results</title>
43 <h1>Python CGI-script results</h1>
46 rv
= rv
+'<br><b>Direct object:</b> %s\n'%pathargs
48 for key
in args
.keys():
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
58 if __name__
== '__main__':