Last active
August 29, 2015 14:00
-
-
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"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> <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