Submit and Succeed: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(10 intermediate revisions by 5 users not shown)
Line 18: Line 18:


## Alter text here
## Alter text here
text = text.upper()
import re
text = re.sub(r"and (\w+)", r"and \1 and peanuts", text, flags = re.I)


print "Content-type: text/html"
print "Content-type: text/html"
Line 35: Line 36:
</head>
</head>
<body>
<body>
<form action="success.cgi">
<form action="">
     <textarea name="text">{0}</textarea>
     <textarea name="text">{0}</textarea>
     <input type="submit">
     <input type="submit">
Line 47: Line 48:
* Eleanor
* Eleanor
*
*
== List of people's work today ==
* Mirjam - [http://pzwart3.wdka.hro.nl/~mdissel/cgi-bin/domestic_violence_replacer.cgi a story about domestic violence (for children)]
* Lieven - [http://pzwart3.wdka.hro.nl/~lspeybroeck/cgi-bin/regexp.cgi Once upon a time they lived happily together]
* Silvio - [http://pzwart3.wdka.hro.nl/~slorusso/cgi-bin/codeis-concrete-poetry.cgi Code Is (Concrete) Poetry]

Latest revision as of 18:48, 17 November 2011

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