Skip to content

Commit 3ed7491

Browse files
committed
Spremembe primerov s predavanj, osnovni model
1 parent e470faa commit 3ed7491

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
auth = dict(
2+
host="baza.fmf.uni-lj.si",
3+
dbname="ime_baze",
4+
user="uporabnisko_ime",
5+
password="geslo"
6+
)

predavanja/primeri/banka/model.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from dataclasses import dataclass
2+
from datetime import datetime
3+
4+
5+
@dataclass
6+
class Kraj:
7+
posta: int
8+
kraj: str
9+
10+
11+
@dataclass
12+
class Oseba:
13+
emso: str
14+
ime: str
15+
priimek: str
16+
naslov: str
17+
kraj: Kraj
18+
19+
20+
@dataclass
21+
class Racun:
22+
stevilka: int
23+
lastnik: Oseba
24+
25+
26+
@dataclass
27+
class Transakcija:
28+
id: int
29+
racun: Racun
30+
znesek: int
31+
cas: datetime = None
32+
opis: str = None

predavanja/primeri/bottle/primeri/01_primeri-bottle/primer1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@route('/')
99
def index():
10-
return 'ŽIVJO svet!'
10+
return 'Živjo svet!'
1111

1212
# Če dopišemo reloader=True, se bo sam restartal vsakič, ko spremenimo datoteko
1313
run(host='localhost', port=8080, reloader=True)

predavanja/primeri/bottle/primeri/01_primeri-bottle/primer3.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ def ucitelji_slabi():
3939

4040

4141
@get('/ucitelji/')
42+
@view('ucitelji.html')
4243
def ucitelji():
4344
c = baza.cursor()
4445
c.execute("SELECT id,ime,povezava FROM ucitelj ORDER BY ime")
4546
# TAKO SE DELA!
46-
return template('ucitelji.html', ucitelji=c)
47+
return dict(ucitelji=c)
4748

4849

4950

@@ -54,4 +55,4 @@ def ucitelji():
5455
baza = sqlite3.connect(baza_datoteka, isolation_level=None)
5556

5657
# poženemo strežnik na portu 8080, glej http://localhost:8080/
57-
run(host='localhost', port=8080)
58+
run(host='localhost', port=8080, reloader=True)

predavanja/primeri/bottle/primeri/01_primeri-bottle/primer4.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ def odjava():
4949
redirect('/prijava')
5050

5151

52+
@get("/google")
53+
def google():
54+
q = request.query.q
55+
return f"""
56+
<html>
57+
<form action="/google" method="GET">
58+
<input name="q" type="text" />
59+
<input type="submit" value="Išči" />
60+
</form>
61+
62+
<a href="https://www.google.com/search?q={q}">Poguglaj {q}!</iframe>
63+
</html>
64+
"""
65+
5266
def preveri(uime, geslo):
5367
return uime=="janez" and geslo=="kranjski"
5468

0 commit comments

Comments
 (0)