change: remove native oidc & before_first_request

This commit is contained in:
2023-06-24 16:43:21 +02:00
parent 3dc8ff03c5
commit 16f56cba7a

View File

@@ -5,23 +5,15 @@ import argparse
import sys
import PIL.Image
import werkzeug.utils
import flask_oidc
import json
app = flask.Flask("Picture factory app", static_folder=None)
## OIDC CONFIG SETUP ##
if os.path.isfile("oidc.json"):
with open("oidc.json") as f:
app.config |= json.load(f)
if not os.path.isfile(app.config["OIDC_CLIENT_SECRETS"]):
raise ValueError("client_secrets.json file is missing in project root")
else:
raise ValueError("OIDC required by environment but not oidc.json file found")
oidc = flask_oidc.OpenIDConnect(app)
PICTURE_DIR = "pictures/"
app.config['MAX_CONTENT_PATH'] = 32+1000*1000
app.config['UPLOAD_FOLDER'] = PICTURE_DIR
app.config['UPLOAD_ENABLED'] = os.path.isfile("./upload.enable")
def generatePicture(pathToOrig, scaleX, scaleY, encoding, crop):
'''Generate an pictures with the requested scales and encoding if it doesn't already exist'''
@@ -149,7 +141,6 @@ def list():
return flask.render_template("index.html", paths=retStringArr)
@app.route("/upload", methods = ['GET', 'POST'])
@oidc.require_login
def upload():
if not app.config['UPLOAD_ENABLED']:
return ("Upload Disabled", 403)
@@ -169,13 +160,6 @@ def upload():
else:
return flask.render_template("upload.html")
@app.before_first_request
def init():
app.config['MAX_CONTENT_PATH'] = 32+1000*1000
app.config['UPLOAD_FOLDER'] = PICTURE_DIR
app.config['UPLOAD_ENABLED'] = os.path.isfile("./upload.enable")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Picture Factory',