-
Notifications
You must be signed in to change notification settings - Fork 8
/
view.py
45 lines (33 loc) · 1011 Bytes
/
view.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
from decorators import address
from helpers import send_response, write_to_db
from renderer import render
@address('about')
def about_handler(request, conn, match=True, data={}):
template = "about.html"
abc = render(template, {'this_is_variable': 'Бул өзгөрмөнүн ордуна барат'})
resp = """\
HTTP/1.1 200 OK
{0}
""".format(abc)
send_response(resp, conn, match)
# @address('shop')
# def shop_handler(request, conn, match=True):
# template = "shop.html"
# render(template, conn, match)
@address('contacts')
def contact_handler(request, conn, match=True,data={}):
template = "contacts.html"
content = render(template)
resp = """\
HTTP/1.1 200 OK
{0}
""".format(content)
write_to_db(match,data)
send_response(resp, conn, match)
@address('products')
def products_handler(request, conn, match=True,data={}):
resp = """\
HTTP/1.1 200 OK
This is product page
"""
send_response(resp, conn, match)