diff options
Diffstat (limited to 'examples/helloworld.cgi')
| -rwxr-xr-x | examples/helloworld.cgi | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/helloworld.cgi b/examples/helloworld.cgi new file mode 100755 index 0000000..bcc15a5 --- /dev/null +++ b/examples/helloworld.cgi @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import cgi + +form = cgi.FieldStorage() +import os + +print 'Content-type: text/html\n' + +if form.getvalue('name'): + print '<html><head><title>Hello!</title></head>' + print '<body>' + print '<h1>Hello %s!</h1>' % form['name'].value +else: + print '<html><head><title>Who is there?</title></head>' + print '<body>' + print '<h1>Who is there?</h1>' + +print '<form action="%s" method="POST">' % os.environ['SCRIPT_NAME'] +print 'What is your name?<br>' +print '<input type="text" name="name" value="%s"><br>' \ + % cgi.escape(form.getvalue('name', ''), 1) +print '<input type="submit" value="That is my name"></form>' +print '</body></html>' |
