Browse Source

mockup for persons

Davide Alberani 9 years ago
parent
commit
070e84bcb1
1 changed files with 23 additions and 4 deletions
  1. 23 4
      eventman_server.py

+ 23 - 4
eventman_server.py

@@ -13,22 +13,41 @@ from tornado.options import define, options
 import tornado.web
 from tornado import gen
 
-
 class MainHandler(tornado.web.RequestHandler):
     @gen.coroutine
     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():
     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",
             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()
 
     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"),
         static_path=os.path.join(os.path.dirname(__file__), "static"),