aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/webui/handlers
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-23 16:39:29 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-23 16:39:29 +0800
commit58bc8b4bca4a0272ea78294d8aa413598eaf75c6 (patch)
treeb8b0bf3c310698b777794b3503fc35a891fc0ee9 /fg21sim/webui/handlers
parent16b75072db5ff7822a6e0d4345f7d73f678fff42 (diff)
downloadfg21sim-58bc8b4bca4a0272ea78294d8aa413598eaf75c6.tar.bz2
webui: Add "from_localhost" to IndexHandler and products template
Diffstat (limited to 'fg21sim/webui/handlers')
-rw-r--r--fg21sim/webui/handlers/index.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/fg21sim/webui/handlers/index.py b/fg21sim/webui/handlers/index.py
index b351619..89d079d 100644
--- a/fg21sim/webui/handlers/index.py
+++ b/fg21sim/webui/handlers/index.py
@@ -11,6 +11,18 @@ from .base import BaseRequestHandler
class IndexHandler(BaseRequestHandler):
"""
Index page handler of the Web UI.
+
+ Attributes
+ ----------
+ from_localhost : bool
+ ``True`` if the request is from the localhost, otherwise ``False``.
"""
+ def initialize(self):
+ """Hook for subclass initialization. Called for each request."""
+ if self.request.remote_ip == "127.0.0.1":
+ self.from_localhost = True
+ else:
+ self.from_localhost = False
+
def get(self):
- self.render("index.html")
+ self.render("index.html", from_localhost=self.from_localhost)