https autoupgrade

This commit is contained in:
trinkey 2024-02-20 19:26:24 -05:00
parent a0a1a0c87c
commit a22aa2bea1
2 changed files with 18 additions and 4 deletions

View file

@ -6,3 +6,5 @@ it's like pronouns.page but i made it
### todo ### todo
* social links * social links
* sexuality/gender flags * sexuality/gender flags
* 404 page
* embed meta tags

View file

@ -1,14 +1,17 @@
CONTENT_DIRECTORY = "./public/"
SAVING_DIRECTORY = "./save/"
UPGRADE_TO_HTTPS = False
import hashlib import hashlib
import shutil import shutil
import flask import flask
import json import json
import os import os
from flask import request
from typing import Union, Callable from typing import Union, Callable
from flask import request, redirect
CONTENT_DIRECTORY = "./public/" from werkzeug.middleware.proxy_fix import ProxyFix
SAVING_DIRECTORY = "./save/"
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -311,5 +314,14 @@ app.route("/api/account/info/<path:user>", methods=["GET"])(api_account_info_)
app.route("/api/account/self", methods=["GET"])(api_account_self) app.route("/api/account/self", methods=["GET"])(api_account_self)
app.route("/api/save", methods=["PATCH"])(api_save) 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__": if __name__ == "__main__":
app.run(debug=True, port=8080) app.run(debug=True, port=8080)