aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/webui/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'fg21sim/webui/app.py')
-rw-r--r--fg21sim/webui/app.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/fg21sim/webui/app.py b/fg21sim/webui/app.py
new file mode 100644
index 0000000..63d80be
--- /dev/null
+++ b/fg21sim/webui/app.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2016 Weitian LI <liweitianux@live.com>
+# MIT license
+
+"""
+Web user interface (UI) of "fg21sim" based upon Tornado_.
+
+.. _Tornado: http://www.tornadoweb.org/
+"""
+
+import os
+
+import tornado.web
+
+from .websocket import EchoWSHandler
+
+
+class IndexHandler(tornado.web.RequestHandler):
+ def get(self):
+ self.render("index.html")
+
+
+_settings = {
+ # The static files will be served from the default "/static/" URI
+ "static_path": os.path.join(os.path.dirname(__file__), "static"),
+ "template_path": os.path.join(os.path.dirname(__file__), "templates"),
+}
+
+
+def make_application(**kwargs):
+ settings = _settings
+ settings.update(kwargs)
+ appplication = tornado.web.Application(
+ handlers=[
+ (r"/", IndexHandler),
+ (r"/ws", EchoWSHandler),
+ ], **settings)
+ return appplication