form.mpy 426 Bytes
Newer Older
Andreas Jung's avatar
Andreas Jung committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# -*- Mode: Python; tab-width: 4 -*-

# send and process a POST form

import sys

# anything on stdin?
data = sys.stdin.read()

form = """<html><form method=POST action="form.mpy">
%s<hr>
<input name=test size=50 value="">
<input type=submit name=search value="Search">
</form></html>"""

if data:
17 18
    import cgi
    info = '<h2>CGI variables:</h2>%s\r\n' % repr(cgi.parse_qs(data))
Andreas Jung's avatar
Andreas Jung committed
19
else:
20 21
    info = ''
    
Andreas Jung's avatar
Andreas Jung committed
22
print form % info