summaryrefslogtreecommitdiff
path: root/src/ssh_login_attempts.py
diff options
context:
space:
mode:
authoruser <user@node5.net>2024-03-23 14:18:25 +0100
committeruser <user@node5.net>2024-03-23 14:18:25 +0100
commitf379b1c78cc224581fac16541e5bc3b6ccbc5dd1 (patch)
treea30a324c14c28662a1fda788ffc71cffaa74dbb6 /src/ssh_login_attempts.py
parent681ba92b4c5a4a600dd029bd0fd2b0a2c482e442 (diff)
rename entry module to ssh_node5_net
Diffstat (limited to 'src/ssh_login_attempts.py')
-rw-r--r--src/ssh_login_attempts.py57
1 files changed, 0 insertions, 57 deletions
diff --git a/src/ssh_login_attempts.py b/src/ssh_login_attempts.py
deleted file mode 100644
index 3da31cc..0000000
--- a/src/ssh_login_attempts.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import logging
-
-import flask
-
-import db_handler
-
-
-class CustomFormatter(logging.Formatter):
- grey = "\x1b[90;20m"
- blue = "\x1b[34;20m"
- yellow = "\x1b[33;20m"
- red = "\x1b[31;20m"
- bold_red = "\x1b[31;1m"
- reset = "\x1b[0m"
- format = "%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s"
-
- FORMATS = {
- logging.DEBUG: grey + format + reset,
- logging.INFO: blue + format + reset,
- logging.WARNING: yellow + format + reset,
- logging.ERROR: red + format + reset,
- logging.CRITICAL: bold_red + format + reset
- }
-
- def format(self, record):
- log_fmt = self.FORMATS.get(record.levelno)
- formatter = logging.Formatter(log_fmt)
- return formatter.format(record)
-
-
-logger = logging.getLogger(__name__)
-logger.root.setLevel(logging.INFO)
-
-stream_handler = logging.StreamHandler()
-stream_handler.setFormatter(CustomFormatter())
-logger.root.addHandler(stream_handler)
-
-app = flask.Flask(__name__, template_folder='templates', static_folder='static', static_url_path='')
-
-@app.route("/password_of_the_month")
-@app.route("/password of the month")
-@app.route("/passwd")
-def password_of_the_month():
- password = db_handler.get_password_of_the_month()
- return password
-
-
-@app.route("/")
-def index():
- latest_loging_attempts = db_handler.get_latest_login_attempts()
- top_usernames = db_handler.get_top('username')
- top_passwords = db_handler.get_top('password')
- return flask.render_template(
- 'index.html',
- latest_login_attempts=latest_loging_attempts,
- top_usernames=top_usernames,
- top_passwords=top_passwords)