#!/usr/bin/python import cgi import random # Header print "Content-Type: text/html" print print "DiceRoller 0.0.1" print "

Simple Diceroller - Now With Chat!

" # Function which allow you to write a message to the chat def writeChat(): print "
" print "" print "" print "
" 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 messages def readChat(): file = open("chat.txt","r") for line in file: print line,"
" print "
" writeChat() # Function which return an integer between 1 and 6 def rollDice(): eyes = random.randint(1,6) print "Dice show",eyes,"eyes
" # Function which return rollDice() four times def showDices(): for i in range(0,4): rollDice() # Run script showDices() print "

" readChat() file.close()