From e47989d80a86bd0311e697b098167dcda8579157 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Wed, 11 Nov 2020 10:36:02 +0000 Subject: [PATCH] Cosmetic fix-up --- src/Alertify/__init__.py | 46 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/Alertify/__init__.py b/src/Alertify/__init__.py index 7ad7959..66c8363 100644 --- a/src/Alertify/__init__.py +++ b/src/Alertify/__init__.py @@ -23,48 +23,52 @@ from .messaging import MessageHandler webapp = Flask(__name__) +# FIXME: * Find a better way to deny FlaskView methods without using a `_` +# prefix or raising a NotFound exception + class Alertify(FlaskView): """ - Main alertify class + Main Alertify class """ route_base = '/' trailing_slash = False def __init__(self): + # Instantiate with defaults self.configure() def configure(self, configfile=None): """ - Configure the object from a configfile + Configure from a configfile """ - try: - _ = request.args + # Deny via HTTP + if request: raise werkzeug.exceptions.NotFound - except RuntimeError: - self.config = Config(configfile) - self.gotify = Gotify( - self.config.gotify_server, - self.config.gotify_port, - self.config.gotify_key_app, - self.config.gotify_key_client, - ) - self.msg_hndlr = MessageHandler( - self.gotify, - self.config.disable_resolved, - self.config.delete_onresolve, - ) + + self.config = Config(configfile) + self.gotify = Gotify( + self.config.gotify_server, + self.config.gotify_port, + self.config.gotify_key_app, + self.config.gotify_key_client, + ) + self.msg_hndlr = MessageHandler( + self.gotify, + self.config.disable_resolved, + self.config.delete_onresolve, + ) def run(self): """ Listen on port and run webserver """ - try: - _ = request.args + # Deny via HTTP + if request: raise werkzeug.exceptions.NotFound - except RuntimeError: - webapp.run(host='0.0.0.0', port=self.config.listen_port) + + webapp.run(host='0.0.0.0', port=self.config.listen_port) @route('/alert', methods=['POST']) def alert(self):