Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Created November 8, 2015 01:31
Show Gist options
  • Select an option

  • Save Teino1978-Corp/cc4243090130f12a9164 to your computer and use it in GitHub Desktop.

Select an option

Save Teino1978-Corp/cc4243090130f12a9164 to your computer and use it in GitHub Desktop.
Python cgi: My attemp to convert from 2.7 to 3.4.1: Source-https://wiki.python.org/moin/CgiScripts
mport cgi
import cgitb; cgitb.enable()
print("Content-type: text/html")
print()
print"""
<html>
<head><title>Sample CGI Script</title></head>
<body>
<h3>Testing stuff</h3>
"""
form = cgi.FieldStorage()
message = form.getvalue("message", "(no message)")
print"""
<p>Previous message: %s</p>
<p>form
<form method="post" action="index.cgi">
<p>message: <input type="text" name="message"/></p>
</form>
</p> #I added this to close the form <p> Code failed without and with it.
</body>
</html>
""" % cgi.escape(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment