User:Lidia.Pereira/PNMIII/CEIII: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "Continuation of this , now handling conflict. <syntax highlight ="python"> #!/usr/bin/env python #-*- coding:utf-8 -*- import cgi, urllib...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<div style="width: 70%;">
Continuation of [[User:Lidia.Pereira/PNMII/WB/CE | this ]], now handling conflict.
Continuation of [[User:Lidia.Pereira/PNMII/WB/CE | this ]], now handling conflict.
http://headroom.pzwart.wdka.hro.nl/~lpereira/cgi-bin/exquisfrontpage.cgi


<syntax highlight ="python">
 
<syntaxhighlight lang="python">
#!/usr/bin/env python
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#-*- coding:utf-8 -*-
Line 48: Line 51:
print """ <a href='exquisfrontpage.cgi'><img src='/cadavrebanner.png' class = 'banner2'/></a> <br>
print """ <a href='exquisfrontpage.cgi'><img src='/cadavrebanner.png' class = 'banner2'/></a> <br>
     <a href='cadavrexquisresults.cgi'><img src='/nonsenselink.png' class='nonsenselink'></a>
     <a href='cadavrexquisresults.cgi'><img src='/nonsenselink.png' class='nonsenselink'></a>
     <p class='exquisrule'> The only rule is that you have to start your contribution with the word you see on the form! </p> """
     <p class='exquisrule'> The only rule is that you have to start your contribution\
with the word you see on the form! </p> """
if writePar:
if writePar:
     print """<p class = 'exquisrule'> There seems to be a conflict, try again please! </p>"""
     print """<p class = 'exquisrule'> There seems to be a conflict, try again please! </p>"""
Line 56: Line 60:
print """<input type='submit' value='Contribute!' class ='button' /> """
print """<input type='submit' value='Contribute!' class ='button' /> """
</syntaxhighlight>
</syntaxhighlight>
</div>

Latest revision as of 14:06, 2 July 2014

Continuation of this , now handling conflict. http://headroom.pzwart.wdka.hro.nl/~lpereira/cgi-bin/exquisfrontpage.cgi


#!/usr/bin/env python
#-*- coding:utf-8 -*-
import cgi, urllib
import cgitb; cgitb.enable()
import urlparse

form = cgi.FieldStorage()
form_text_content = form.getvalue('textcontent')
form_last_word = form.getvalue('lastword')

database = open("database.txt")
lines = database.readlines()

def last_Word():
    for line in lines:
        a = line.split()
        for word in a:
            lastword = word
    return lastword
writePar = False
lastWord = last_Word()
x = 0
story = " "
if lastWord == form_last_word and form_text_content != None:
    story = last_Word()
    database = open("database.txt","a")
    database.write(form_text_content + "\n")
    database = open("database.txt")
    lines = database.readlines() 
    lastWord = last_Word()
elif lastWord != form_last_word and form_text_content != None:
    writePar = True
print "Content-Type: text/html"
print 
print """
    <!DOCTYPE html>
    <html>
    <head>
    <link href='http://fonts.googleapis.com/css?family=Share+Tech+Mono' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' type='text/css' href='/cadavreexquiscss.css'>
    <title>Cadavre Exquis</title>
    </head>
    <body>"""

print """ <a href='exquisfrontpage.cgi'><img src='/cadavrebanner.png' class = 'banner2'/></a> <br>
    <a href='cadavrexquisresults.cgi'><img src='/nonsenselink.png' class='nonsenselink'></a>
    <p class='exquisrule'> The only rule is that you have to start your contribution\
 with the word you see on the form! </p> """
if writePar:
    print """<p class = 'exquisrule'> There seems to be a conflict, try again please! </p>"""
print """<form method='post'>
    <input type='text' name ='textcontent' id='reply' size='121' class ='exquis' placeholder='"""+lastWord+"""' />
    <input type='hidden' name ='lastword' value = '"""+ lastWord +"""' /> """
print """<input type='submit' value='Contribute!' class ='button' /> """