mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:21:31 +00:00
Create initial version of controller
This commit is contained in:
parent
95e1f907ee
commit
c015727153
0
src/controller/__init__.py
Normal file
0
src/controller/__init__.py
Normal file
19
src/controller/app.py
Normal file
19
src/controller/app.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from tornado.ioloop import IOLoop
|
||||||
|
from tornado.web import Application
|
||||||
|
|
||||||
|
from tfw.config import CRP_LISTENER_PORT, AVATAO_SECRET
|
||||||
|
from .handlers import SolutionCheckHandler, TestHandler
|
||||||
|
from tfw.networking.solvable_connector import SolvableConnector
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
solvable_connector = SolvableConnector()
|
||||||
|
routes = [
|
||||||
|
(r'/{secret}/'.format(secret=AVATAO_SECRET), SolutionCheckHandler, {'solvable_connector': solvable_connector}),
|
||||||
|
(r'/{secret}/test'.format(secret=AVATAO_SECRET), TestHandler, {'solvable_connector': solvable_connector})
|
||||||
|
]
|
||||||
|
app = Application(
|
||||||
|
routes
|
||||||
|
)
|
||||||
|
app.listen(CRP_LISTENER_PORT)
|
||||||
|
IOLoop.instance().start()
|
2
src/controller/handlers/__init__.py
Normal file
2
src/controller/handlers/__init__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
from .solution_check_handler import SolutionCheckHandler
|
||||||
|
from .test_handler import TestHandler
|
11
src/controller/handlers/solution_check_handler.py
Normal file
11
src/controller/handlers/solution_check_handler.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from tornado.web import RequestHandler
|
||||||
|
|
||||||
|
|
||||||
|
class SolutionCheckHandler(RequestHandler):
|
||||||
|
def initialize(self, solvable_connector):
|
||||||
|
self.solvable_connector = solvable_connector
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
self.solvable_connector.send('solution_check', {})
|
||||||
|
resp_key, resp_data = self.solvable_connector.recv()
|
||||||
|
return resp_data
|
11
src/controller/handlers/test_handler.py
Normal file
11
src/controller/handlers/test_handler.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from tornado.web import RequestHandler
|
||||||
|
|
||||||
|
|
||||||
|
class TestHandler(RequestHandler):
|
||||||
|
def initialize(self, solvable_connector):
|
||||||
|
self.solvable_connector = solvable_connector
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
self.solvable_connector.send('test', {})
|
||||||
|
resp_key, resp_data = self.solvable_connector.recv()
|
||||||
|
return resp_data
|
Loading…
Reference in New Issue
Block a user