https autoupgrade
This commit is contained in:
parent
a0a1a0c87c
commit
a22aa2bea1
2 changed files with 18 additions and 4 deletions
|
@ -6,3 +6,5 @@ it's like pronouns.page but i made it
|
|||
### todo
|
||||
* social links
|
||||
* sexuality/gender flags
|
||||
* 404 page
|
||||
* embed meta tags
|
||||
|
|
20
_server.py
20
_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/<path:user>", 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)
|
||||
|
|
Loading…
Reference in a new issue