Add Web.configure

This commit is contained in:
Andrew Svetlov 2015-11-30 14:58:49 +02:00
parent 2bfaaca817
commit 0484310513
2 changed files with 11 additions and 1 deletions

View File

@ -45,3 +45,11 @@ class Web:
@asyncio.coroutine
def protected(self, request):
pass
@asyncio.cororutine
def configure(self, app):
app.add_route('GET', '/', self.index, name='index')
app.add_route('POST', '/login', self.login, name='login')
app.add_route('POST', '/logout', self.logout, name='logout')
app.add_route('GET', '/public', self.public, name='public')
app.add_route('GET', '/protected', self.protected, name='protected')

View File

@ -10,6 +10,7 @@ from aioredis import create_pool
from demo.db_auth import DBAuthorizationPolicy
from demo.handlers import Web
@asyncio.coroutine
@ -25,7 +26,8 @@ def init(loop):
SessionIdentityPolicy(),
DBAuthorizationPolicy(dbengine))
app.add_route()
web_handlers = Web()
yield from web_handlers.configure(app)
handler = app.make_handler()
srv = yield from loop.create_server(handler, '127.0.0.1', 8080)