Submit and Succeed

From XPUB & Lens-Based wiki

Some examples of regular expressions

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
import re
text = re.sub(r"and (\w+)", r"and \1 and peanuts", text, flags = re.I)

print "Content-type: text/html"
print
print """
<html>
<head>
<style>
textarea {{
    font-size: 32px;
    width: 100%;
    border: 4px solid black;
    height: 400px;        
}}
</style>
</head>
<body>
<form action="">
    <textarea name="text">{0}</textarea>
    <input type="submit">
</form>
</body>
</html>
""".format(text)

Afternoon Tutorial

  • Eleanor

List of people's work today