Message server
Using Flask:
The client IP address range here is placeholder only (192.168.0.1 .. 192.168.0.3). Depending on your domain configuration, edit the IP values as needed. You also need to change the host IP from the loopback (127.0.0.1) to your domain IP, and enable firewall rules.
message_server.py
from flask import * app = Flask(__name__) app.secret_key = "qwertyuiop" import hashlib password = '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8' # Unsalted SHA256 hash for 'password' # Fake LAN IP addresses, replace with real IP addresses once known: messages = { '192.168.0.1':['Your books are overdue at the library.','Netball practise this afternoon at 3pm.'], '192.168.0.2':['Sushi is $3 at the tuckshop today.','Music class is in the library today.'], '192.168.0.3':['Check out the new video on Youtube.',], } @app.route("/") def root(): return render_template("mail.html", content = messages.get(request.remote_addr), session = session ) @app.route("/login", methods=["post"]) def login(): plain_text = request.form["password"] hash_text = hashlib.sha256( plain_text.encode('utf-8') ).hexdigest() if hash_text == password: session['authenticated'] = True return redirect("/") # Remember to edit host IP to your local IP: app.run(debug=True, host="127.0.0.1", port=5000)
Put the following HTML template into a templates folder:
templates\mail.html
{% if 'authenticated' not in session %} <form method="post" action="/login"> enter password: <input type="text" name="password"> <input type="submit" value="login"> </form> {% else %} {% if content %} {% for msg in content %} {{msg}} <hr> {% endfor %} {% else %} <i>no messages for you!</i> {% endif %} {% endif %}