-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvislice.py
53 lines (37 loc) · 1.38 KB
/
vislice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import bottle
import model
SKRIVNOST = 'moja_prva_skrivnost'
DATOTEKA_S_STANJEM = 'stanje.json'
DATOTEKA_Z_BESEDAMI = 'besede.txt'
vislice = model.Vislice(DATOTEKA_S_STANJEM, DATOTEKA_Z_BESEDAMI)
vislice.nalozi_igre_iz_datoteke()
@bottle.get('/')
def index():
return bottle.template('index.tpl')
@bottle.post('/nova_igra/')
def nova_igra():
id_igre = vislice.nova_igra()
bottle.response.set_cookie('idigre', 'idigre{}'.format(id_igre), secret=SKRIVNOST, path='/')
bottle.redirect('/igra/')
@bottle.get('/igra/')
def pokazi_igro():
id_igre = int(bottle.request.get_cookie('idigre', secret=SKRIVNOST).split('e')[1])
igra, poskus = vislice.igre[id_igre]
return bottle.template('igra.tpl',
igra=igra,
poskus=poskus)
@bottle.post('/igra/')
def ugibaj():
id_igre = int(bottle.request.get_cookie('idigre', secret=SKRIVNOST).split('e')[1])
crka = bottle.request.forms.getunicode('crka')
vislice.ugibaj(id_igre, crka)
bottle.redirect('/igra/')
@bottle.get('/statistika/')
def pokazi_statistiko():
slovar_statistik = model.statistika(DATOTEKA_S_STANJEM)
return bottle.template('statistika.tpl',
slovar_statistik=slovar_statistik)
@bottle.get('/img/<picture>')
def serve_pictures(picture):
return bottle.static_file(picture, root='img')
bottle.run(reloader=True, debug=True)