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.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/fg21sim/webui/app.py b/fg21sim/webui/app.py
index 8199aa7..004be8d 100644
--- a/fg21sim/webui/app.py
+++ b/fg21sim/webui/app.py
@@ -16,6 +16,7 @@ import os
import tornado.web
from .websocket import FG21simWSHandler
+from ..configs import ConfigManager
class IndexHandler(tornado.web.RequestHandler):
@@ -23,23 +24,21 @@ class IndexHandler(tornado.web.RequestHandler):
self.render("index.html")
-_settings = {
- # The static files will be served from the default "/static/" URI.
- # Recommend to use `{{ static_url(filepath) }}` in the templates.
- "static_path": os.path.join(os.path.dirname(__file__), "static"),
- "template_path": os.path.join(os.path.dirname(__file__), "templates"),
-}
+class Application(tornado.web.Application):
+ configmanager = ConfigManager()
-
-# FIXME:
-# * Subclass on `tornado.web.Application`
-# * hold the attributes (e.g., configs, console) ??
-def make_application(**kwargs):
- settings = _settings
- settings.update(kwargs)
- appplication = tornado.web.Application(
- handlers=[
- (r"/", IndexHandler),
+ def __init__(self, **kwargs):
+ handlers = [
+ (r"/", IndexHandler),
(r"/ws", FG21simWSHandler),
- ], **settings)
- return appplication
+ ]
+ settings = {
+ # The static files will be served from the default "/static/" URI.
+ # Recommend to use `{{ static_url(filepath) }}` in the templates.
+ "static_path": os.path.join(os.path.dirname(__file__),
+ "static"),
+ "template_path": os.path.join(os.path.dirname(__file__),
+ "templates"),
+ }
+ settings.update(kwargs)
+ super().__init__(handlers, **settings)