|
@@ -13,22 +13,41 @@ from tornado.options import define, options
|
|
import tornado.web
|
|
import tornado.web
|
|
from tornado import gen
|
|
from tornado import gen
|
|
|
|
|
|
-
|
|
|
|
class MainHandler(tornado.web.RequestHandler):
|
|
class MainHandler(tornado.web.RequestHandler):
|
|
@gen.coroutine
|
|
@gen.coroutine
|
|
def get(self):
|
|
def get(self):
|
|
- self.redirect('/static/html/index.html')
|
|
|
|
|
|
+ self.redirect('/index.html')
|
|
|
|
+
|
|
|
|
+MOCKUP_PERSONS = [
|
|
|
|
+ {'name': 'Silvia', 'surname': 'Castellari',
|
|
|
|
+ 'email': 'hackinbo.it@gmail.com',
|
|
|
|
+ 'id': 1},
|
|
|
|
+ {'name': 'Daniele', 'surname': 'Castellari',
|
|
|
|
+ 'email': 'hackinbo.it@gmail.com',
|
|
|
|
+ 'id': 2},
|
|
|
|
+ {'name': 'Mario', 'surname': 'Anglani',
|
|
|
|
+ 'email': 'hackinbo.it@gmail.com',
|
|
|
|
+ 'id': 3}]
|
|
|
|
+
|
|
|
|
|
|
|
|
+class PersonsHandler(tornado.web.RequestHandler):
|
|
|
|
+ @gen.coroutine
|
|
|
|
+ def get(self, id_=None):
|
|
|
|
+ self.write({'persons': MOCKUP_PERSONS})
|
|
|
|
|
|
def main():
|
|
def main():
|
|
define("port", default=5242, help="run on the given port", type=int)
|
|
define("port", default=5242, help="run on the given port", type=int)
|
|
|
|
+ define("data", default=os.path.join(os.path.dirname(__file__), "data"),
|
|
|
|
+ help="specify the directory used to store the data")
|
|
|
|
+ define("debug", default=False, help="run in debug mode")
|
|
define("config", help="read configuration file",
|
|
define("config", help="read configuration file",
|
|
callback=lambda path: tornado.options.parse_config_file(path, final=False))
|
|
callback=lambda path: tornado.options.parse_config_file(path, final=False))
|
|
- define("debug", default=False, help="run in debug mode")
|
|
|
|
tornado.options.parse_command_line()
|
|
tornado.options.parse_command_line()
|
|
|
|
|
|
application = tornado.web.Application([
|
|
application = tornado.web.Application([
|
|
- (r"/(?:index.html)?", MainHandler),
|
|
|
|
|
|
+ (r"/persons/?(?P<id_>\d+)?", PersonsHandler),
|
|
|
|
+ (r"/", MainHandler),
|
|
|
|
+ (r'/(.*)', tornado.web.StaticFileHandler, {"path": "angular_app"})
|
|
],
|
|
],
|
|
template_path=os.path.join(os.path.dirname(__file__), "templates"),
|
|
template_path=os.path.join(os.path.dirname(__file__), "templates"),
|
|
static_path=os.path.join(os.path.dirname(__file__), "static"),
|
|
static_path=os.path.join(os.path.dirname(__file__), "static"),
|