Add Web.configure
This commit is contained in:
parent
2bfaaca817
commit
0484310513
|
@ -45,3 +45,11 @@ class Web:
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def protected(self, request):
|
def protected(self, request):
|
||||||
pass
|
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')
|
||||||
|
|
|
@ -10,6 +10,7 @@ from aioredis import create_pool
|
||||||
|
|
||||||
|
|
||||||
from demo.db_auth import DBAuthorizationPolicy
|
from demo.db_auth import DBAuthorizationPolicy
|
||||||
|
from demo.handlers import Web
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -25,7 +26,8 @@ def init(loop):
|
||||||
SessionIdentityPolicy(),
|
SessionIdentityPolicy(),
|
||||||
DBAuthorizationPolicy(dbengine))
|
DBAuthorizationPolicy(dbengine))
|
||||||
|
|
||||||
app.add_route()
|
web_handlers = Web()
|
||||||
|
yield from web_handlers.configure(app)
|
||||||
|
|
||||||
handler = app.make_handler()
|
handler = app.make_handler()
|
||||||
srv = yield from loop.create_server(handler, '127.0.0.1', 8080)
|
srv = yield from loop.create_server(handler, '127.0.0.1', 8080)
|
||||||
|
|
Loading…
Reference in New Issue