File: echo.cgi

package info (click to toggle)
python-mechanize 1%3A0.4.8%2Bpypi-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,612 kB
  • sloc: python: 16,644; makefile: 11
file content (26 lines) | stat: -rwxr-xr-x 579 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python3
# -*-python-*-

print "Content-Type: text/html\n"
import sys
import os
import string
import cgi

from types import ListType

print "<html><head><title>Form submission parameters</title></head>"
form = cgi.FieldStorage()
print "<p>Received parameters:</p>"
print "<pre>"
for k in form.keys():
    v = form[k]
    if isinstance(v, ListType):
        vs = []
        for item in v:
            vs.append(item.value)
        text = string.join(vs, ", ")
    else:
        text = v.value
    print "%s: %s" % (cgi.escape(k), cgi.escape(text))
print "</pre></html>"