from http import HTTPMethod, HTTPStatus from flask import Flask, Response, request, send_file from os import urandom from threading import Thread SERVER_IP: str = "10.8.10.221" HTTP_HOST: str = "sniphbank.com" HTTP_PORT: int = 80 HTTPS_PORT: int = 443 DEBUG: bool = False # Required to be in global scope app = Flask(__name__) app.secret_key = urandom(24) http_thread = Thread( name="HTTP-Thread", target=app.run, kwargs={"host": SERVER_IP, "port": HTTP_PORT} ) https_thread = Thread( name="HTTPS-Thread", target=app.run, kwargs={ "host": SERVER_IP, "port": HTTPS_PORT, "ssl_context": ("./cert.pem", "./key.pem"), }, ) @app.route("/") def index(): return send_file("index.html") @app.route("/login", methods=[HTTPMethod.POST]) def login(): # There isn't really a reason to validate the user for the demo, # just decide on a username that might pertain to whomever's # personal information # # user = request.form["username"] # password = request.form["password"] # # if user != "testuser": # return Response("User not found", HTTPStatus.UNAUTHORIZED) # if password != "testpass": # return Response("Incorrect password", HTTPStatus.UNAUTHORIZED) return send_file("./account.html") @app.route("/css/style.css", methods=[HTTPMethod.GET]) def stylesheet(): return send_file("./css/style.css") @app.route("/favicon.ico", methods=[HTTPMethod.GET]) def favicon(): return send_file("./favicon.ico") if __name__ == "__main__": try: http_thread.start() https_thread.start() while True: pass except KeyboardInterrupt: pass finally: http_thread.join() https_thread.join()