All pastes #613380 Raw Edit

Kris

public python v1 · immutable
·published 2007-07-10 23:12 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():#	msgs = open("chat.txt","w")	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 != "" and msg != " "):		print "Message:", msg#		msgs.write("msg")#	msgs.close()# Function which shows text in a file - all the messagesdef readChat():	global msgs	msgs = open("chat.txt","r")	filedata = msgs.readlines()	for msgs in filedata:		print msgs,"<br />"	print "<br />"	msgs.close()	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()msgs.close()