-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvislice.py
More file actions
61 lines (36 loc) · 1.12 KB
/
Copy pathvislice.py
File metadata and controls
61 lines (36 loc) · 1.12 KB
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
54
55
56
57
58
59
60
61
import bottle
import model
SKRIVNI_KLJUC = 'Zadnji teden predavanj!'
vislice = model.Vislice('stanje.json')
#
##testiranje
#id_testne_igre = vislice.nova_igra()
#(testna_igra, poskus) = vislice.igre[id_testne_igre]
#
##testni
@bottle.get('/')
def prva_stran():
return bottle.template('index.tpl')
@bottle.post('/nova_igra/')
def zacni_novo_igro():
# naredi novo igro in preusmeri na nov naslov
id_igre = vislice.nova_igra()
bottle.response.set_cookie('id_igre', id_igre, secret=SKRIVNI_KLJUC, path='/')
bottle.redirect('/igra/')
return
@bottle.get('/igra/')
def prikazi_igro():
id_igre = bottle.request.get_cookie('id_igre', secret=SKRIVNI_KLJUC)
(igra, poskus) = vislice.igre[id_igre]
return bottle.template(
'igra.tpl', igra = igra ,
id_igre = id_igre,
poskus = poskus
)
@bottle.post('/igra/')
def ugibaj_crko():
crka = bottle.request.forms.getunicode('poskus')
id_igre = bottle.request.get_cookie('id_igre', secret=SKRIVNI_KLJUC)
vislice.ugibaj(id_igre, crka)
bottle.redirect('/igra/')
bottle.run(debug=True, reloader=True)