User:Lidia.Pereira/PNMII/WB/CE: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "Rough version: <source lang = "python" > #!/usr/bin/env python #-*- coding:utf-8 -*- import cgi, cgitb import urlparse, urllib form = cgi.FieldStorage() if form.getvalue('...")
 
(Blanked the page)
Line 1: Line 1:
Rough version:


<source lang = "python" >
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import cgi, cgitb
import urlparse, urllib
form = cgi.FieldStorage()
if form.getvalue('textcontent'):
  text_content = form.getvalue('textcontent')
else:
  text_content = "Not entered"
dict = {}
dict["entry"] = text_content
database = open("database.txt","a")
database.write(urllib.urlencode(dict) + "\n")
database.close()
print "Content-Type: text/html"
print
print """
    <!DOCTYPE html>
    <html>
    <head>
    <title>Technical Issues</title>
    <style>
    form {
        border-style: none;
        outline-color: none;
    }
    </style>
    </head>
    <body>
    """
database = open("database.txt")
lines = database.readlines()
def last_Word():
    for line in lines:
        neatly = urlparse.parse_qs(line.rstrip())
        parsed = neatly["entry"]
        parsed = str(parsed[len(parsed)-1])
        a = parsed.split()
        for word in a:
            lastword = word
    return lastword
lastWord = last_Word()
if lines > 7:
    for line in lines:
        neat = urlparse.parse_qs(line.rstrip())
        print """
        <p> """+neat["entry"][0]+""" </p>
        """
print """
    <form method='post'>
    <textarea name='textcontent' cols='40' rows='4'>
    """+lastWord+"""
    </textarea>
    <input type='submit' value='Publish, please!' />
    </form>
    </body>
    </html> """
</source>

Revision as of 02:35, 4 March 2014