All pastes #613316 Raw Edit

Kris

public python v1 · immutable
·published 2007-07-10 22:22 UTC
rendered paste body
#!/usr/bin/pythonimport cgiimport random# Headerprint "Content-Type: text/html"printprint "<title>DiceRoller 0.0.1</title>"print "<h1>Simple Diceroller - Now With Chat!</h1>"              # Function which allow you to write a message to the chatdef writeChat():        print "<form action='diceroller.py' method='send'>"        print "<input type='text' name='message' />"        print "<input type='submit' value='Send' />"        print "</form>"        form = cgi.FieldStorage()        msg = form["message"].value        if (msg != "" or msg != " "):                print "Message:", form['message'].value# Function which shows text in a file - all the messagesdef readChat():        file = open("chat.txt","r")        for line in file:                print line,"<br />"        print "<br />"        writeChat()# Function which return an integer between 1 and 6def rollDice():        eyes = random.randint(1,6)        print "Dice show",eyes,"eyes<br />"# Function which return rollDice() four timesdef showDices():        for i in range(0,4):                rollDice()# Run scriptshowDices()print "<br /><br />"readChat()file.close()