From f1bd912c85710bee5aae7a3112bdcfacd062c466 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 17 Nov 2016 16:42:38 +0800 Subject: webui: Move "password" option definition to "login.py" NOTE: By using the "tornado.options", each module can defines its own options, which are added to the global namespace. And the defined options can also be used by other modules. --- bin/fg21sim-webui | 7 ++----- fg21sim/webui/handlers/login.py | 10 +++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/fg21sim-webui b/bin/fg21sim-webui index e2ecff5..20d1a36 100755 --- a/bin/fg21sim-webui +++ b/bin/fg21sim-webui @@ -29,8 +29,8 @@ from fg21sim.utils import setup_logging from fg21sim.webui import Application -# Define options in the global namespace -# These options can also be used in other modules +# Each module can defines its own options, which are added to the global +# namespace. Therefore the defined options can also be used by other modules. define("host", default="localhost", type=str, help=("IP address or hostname the server will listen on. " "Specify '0.0.0.0' or '' (empty string) to listen on " @@ -45,9 +45,6 @@ define("hosts_allowed", default="any", type=str, "'192.168.0.0/24'. " "Specify 'any' to allow any hosts. " "Note that the localhost/127.0.0.1 is always allowed.")) -define("password", type=str, - help=("Password authentication to access the Web UI. " - "If not specified, then all accesses are allowed.")) def main(): diff --git a/fg21sim/webui/handlers/login.py b/fg21sim/webui/handlers/login.py index 4529005..5a9987a 100644 --- a/fg21sim/webui/handlers/login.py +++ b/fg21sim/webui/handlers/login.py @@ -3,14 +3,22 @@ """ Login handler + +Currently, the login is simply authenticated by a plain password. """ -from tornado.options import options +from tornado.options import define, options from tornado.escape import xhtml_escape from .base import BaseRequestHandler +# Each module defines its own options, which are added to the global namespace +define("password", type=str, + help=("Password authentication to access the Web UI. " + "If not specified, then all accesses are allowed.")) + + class LoginHandler(BaseRequestHandler): """ Login page handler of the Web UI. -- cgit v1.2.2