aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/webui/handlers/index.py
blob: 89d079dece8d0653a424a0687441afdb10d7057e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright (c) 2016 Weitian LI <liweitianux@live.com>
# MIT license

"""
Index page handler
"""

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", from_localhost=self.from_localhost)