Skip to content

Instantly share code, notes, and snippets.

@153
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 153/11398572 to your computer and use it in GitHub Desktop.
Save 153/11398572 to your computer and use it in GitHub Desktop.
Simple game which generates income. donors.txt is a csv such like "name optionalurl points"
import csv
def head():
print("""<html>
<head><title>4x13 :: game</title>
<link rel="stylesheet" type="text/css" href="/style.css"></head>
<body><h1>game</h1>
<a href="/"><img src="/game.png"></a><br>
<hr><center><table>
<tr><td colspan="3"><b>winners</b>: <i>game has no losers</i>
<tr><td>&nbsp;<td>name:<td>score:
<!-- Donor's list @ /game/donors.txt -->\n""")
def table():
with open("donors.txt") as db:
num=0
reader = csv.reader(db, delimiter=' ')
for row in reader:
if row[0][:1] not in ("", "#"):
num+=1
print("<tr><td align='right'>"+str(num)+".")
if len(row)==2:
print("<td>"+row[0])
else:
print("<td><a href='//"+row[1]+"'>"+row[0]+"</a>")
print("<td align='right'>"+row[-1]+"\n")
def foot():
print("""<tr><td colspan="3"><em>(note: 1 point = $1 donated)</em>
</table><hr>
donation method</body></html>""")
head()
table()
foot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment