diff --git a/README.md b/README.md index 8bd39ea..6717850 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,5 @@ it's like pronouns.page but i made it ### todo * social links * sexuality/gender flags +* 404 page +* embed meta tags diff --git a/_server.py b/_server.py index 0bbed93..fcc6fbf 100644 --- a/_server.py +++ b/_server.py @@ -1,14 +1,17 @@ +CONTENT_DIRECTORY = "./public/" +SAVING_DIRECTORY = "./save/" + +UPGRADE_TO_HTTPS = False + import hashlib import shutil import flask import json import os -from flask import request from typing import Union, Callable - -CONTENT_DIRECTORY = "./public/" -SAVING_DIRECTORY = "./save/" +from flask import request, redirect +from werkzeug.middleware.proxy_fix import ProxyFix app = flask.Flask(__name__) @@ -311,5 +314,14 @@ app.route("/api/account/info/", methods=["GET"])(api_account_info_) app.route("/api/account/self", methods=["GET"])(api_account_self) app.route("/api/save", methods=["PATCH"])(api_save) +if UPGRADE_TO_HTTPS: + app.wsgi_app = ProxyFix(app.wsgi_app) + + @app.before_request + def enforce_https(): + if not request.is_secure: + url = request.url.replace('http://', 'https://', 1) + return redirect(url, code=301) + if __name__ == "__main__": app.run(debug=True, port=8080)