Submit and Succeed: Difference between revisions
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
* Forms in HTML: http://www.w3.org/TR/html4/interact/forms.html | * Forms in HTML: http://www.w3.org/TR/html4/interact/forms.html | ||
Behold the self-posting form: | |||
<source lang="python"> | |||
#!/usr/bin/env python | |||
#-*- coding:utf-8 -*- | |||
import cgi | |||
import cgitb; cgitb.enable() | |||
query = cgi.FieldStorage() | |||
text = query.getvalue("text", "") | |||
## Alter text here | |||
text = text.upper() | |||
print "Content-type: text/html" | |||
print | |||
print """ | |||
<html> | |||
<head></head> | |||
<body> | |||
<form action="success.cgi"> | |||
<textarea name="text" style="font-size: width: 100%; border: 4px solid black; height: 100px">{0}</textarea> | |||
<input type="submit"> | |||
</form> | |||
</body> | |||
</html> | |||
""".format(text) | |||
</source> | |||
== Afternoon Tutorial == | == Afternoon Tutorial == | ||
* Eleanor | * Eleanor | ||
* | * |
Revision as of 14:26, 17 November 2011
- Charles Hayden's Eliza: http://chayden.net/eliza/Eliza.html
- Regular Expressions in Python: http://docs.python.org/library/re.html
Some examples of regular expressions
- Forms in HTML: http://www.w3.org/TR/html4/interact/forms.html
Behold the self-posting form:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import cgi
import cgitb; cgitb.enable()
query = cgi.FieldStorage()
text = query.getvalue("text", "")
## Alter text here
text = text.upper()
print "Content-type: text/html"
print
print """
<html>
<head></head>
<body>
<form action="success.cgi">
<textarea name="text" style="font-size: width: 100%; border: 4px solid black; height: 100px">{0}</textarea>
<input type="submit">
</form>
</body>
</html>
""".format(text)
Afternoon Tutorial
- Eleanor