summaryrefslogtreecommitdiff
path: root/src/ssh_node5_net.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ssh_node5_net.py')
-rw-r--r--src/ssh_node5_net.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ssh_node5_net.py b/src/ssh_node5_net.py
index 3da31cc..1247603 100644
--- a/src/ssh_node5_net.py
+++ b/src/ssh_node5_net.py
@@ -1,4 +1,5 @@
import logging
+import datetime
import flask
@@ -37,6 +38,7 @@ 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")
@@ -45,13 +47,21 @@ def password_of_the_month():
return password
+def format_time(input: datetime.datetime) -> str:
+ return input.strftime('%e %b %Y %H:%M')
+
@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')
+ histogram = db_handler.get_histogram()
+ histogram_data = [a['total_count'] for a in histogram]
+ histogram_labels = [format_time(a['date']) for a in histogram]
return flask.render_template(
'index.html',
latest_login_attempts=latest_loging_attempts,
top_usernames=top_usernames,
- top_passwords=top_passwords)
+ top_passwords=top_passwords,
+ histogram_data=histogram_data,
+ histogram_labels=histogram_labels)