-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
36 lines (23 loc) · 747 Bytes
/
app.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
from werkzeug import Request, ClosingIterator
from werkzeug.exceptions import HTTPException
from urls import url_map
import views
class Application(object):
def __init__(self):
pass
def __call__(self, environ, start_response):
try:
self._setup()
request = Request(environ)
adapter = url_map.bind_to_environ(environ)
endpoint, values = adapter.match()
handler = getattr(views, endpoint)
response = handler(request, **values)
except HTTPException, e:
'''5xx'''
return ClosingIterator(e(environ, start_response), self._cleanup)
return ClosingIterator(response(environ, start_response), self._cleanup)
def _setup(self):
pass
def _cleanup(self):
pass