diff --git a/.gitignore b/.gitignore index 8c5c3bb..b14bd21 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ sites static/css/uikit-rtl.css static/css/uikit-rtl.min.css static/css/uikit.css -static/css/uikit.min.css \ No newline at end of file +static/css/uikit.min.css +instance/application.cfg.py \ No newline at end of file diff --git a/application/recipes/__pycache__/recipes_api.cpython-313.pyc b/application/recipes/__pycache__/recipes_api.cpython-313.pyc index 3a69b74..152fcf9 100644 Binary files a/application/recipes/__pycache__/recipes_api.cpython-313.pyc and b/application/recipes/__pycache__/recipes_api.cpython-313.pyc differ diff --git a/application/recipes/recipes_api.py b/application/recipes/recipes_api.py index 936df8b..9fa48ab 100644 --- a/application/recipes/recipes_api.py +++ b/application/recipes/recipes_api.py @@ -161,7 +161,8 @@ def uploadImage(recipe_id): def get_image(recipe_id): site_name = session['selected_site'] picture_path = database_recipes.getPicturePath(site_name, (recipe_id,)) - return send_from_directory('static/pictures/recipes', picture_path) + path = f"{current_app.config['UPLOAD_FOLDER']}/recipes" + return send_from_directory(path, picture_path) @recipes_api.route('/deleteRecipeItem', methods=["POST"]) @access_api.login_required diff --git a/instance/application.cfg.py b/instance/application.cfg.py index c18dd2c..ae1ad1b 100644 --- a/instance/application.cfg.py +++ b/instance/application.cfg.py @@ -1,3 +1,18 @@ VAPID_PUBLIC_KEY = "BIbaHOqZcTunzAeb9p1hCWBo1DeJN0NVf2WVNSrsLZ2e50vhBno5dJuRAB1NLNXIeeQYr_x-1fSifJBGfUKd6QM" VAPID_PRIVATE_KEY = "l2wLDKWJDMkytDSN8s9iu9Y3-5qrIMy_OreUC3vDHtI" -VAPID_CLAIM_EMAIL = "jadowyne.ulve@outlook.com" \ No newline at end of file +VAPID_CLAIM_EMAIL = "jadowyne.ulve@outlook.com" + +APP_SECRET = "11gs22h2h1a4h6ah8e413a45" + +UPLOAD_FOLDER = "E:/code/pantry-track/uploads" +FILES_FOLDER = "E:/code/pantry-track/files" + +OAUTH_NAME = "authentik" +OAUTH_CLIENT_ID = "gh8rLyXC6hfI7W5mDX26OJFGHxmU0nMzeYl3B04G" +OAUTH_CLIENT_SECRET = "aRHyAkDDeU22s69Ig0o7f46Xn3HCnB8guZoMHuA23B7x1e2YL8FhAqZbu1f3naiaLyTLi9ICIiBc6dxOp5eIO4fEI9paL2NwKXmqYCRmzNzWAfwmcsIh2qTlQfAfsh6e" +OAUTH_ACCESS_TOKEN_URL = "https://auth.treehousefullofstars.com/application/o/token/" +OAUTH_AUTHORIZE_URL = "https://auth.treehousefullofstars.com/application/o/authorize/" +OAUTH_USERINFO_ENDPOINT = "https://auth.treehousefullofstars.com/application/o/userinfo/" +OAUTH_API_BASE_URL = "https://auth.treehousefullofstars.com/application/o/" +OAUTH_JWKS_URI = "https://auth.treehousefullofstars.com/application/o/pantry/jwks/" +OAUTH_CLIENT_KWARGS = {'scope': 'openid profile email'} \ No newline at end of file diff --git a/webserver.py b/webserver.py index 01f9275..bf90a95 100644 --- a/webserver.py +++ b/webserver.py @@ -18,27 +18,24 @@ from outh import oauth app = Flask(__name__, instance_relative_config=True) oauth.init_app(app) swagger = Swagger(app) -UPLOAD_FOLDER = 'static/pictures' -FILES_FOLDER = 'static/files' app.config.from_pyfile('application.cfg.py') -app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER -app.config['FILES_FOLDER'] = FILES_FOLDER +print(app.config['UPLOAD_FOLDER']) oauth.register( - name='authentik', - client_id='gh8rLyXC6hfI7W5mDX26OJFGHxmU0nMzeYl3B04G', - client_secret='aRHyAkDDeU22s69Ig0o7f46Xn3HCnB8guZoMHuA23B7x1e2YL8FhAqZbu1f3naiaLyTLi9ICIiBc6dxOp5eIO4fEI9paL2NwKXmqYCRmzNzWAfwmcsIh2qTlQfAfsh6e', - access_token_url="https://auth.treehousefullofstars.com/application/o/token/", - authorize_url="https://auth.treehousefullofstars.com/application/o/authorize/", - userinfo_endpoint="https://auth.treehousefullofstars.com/application/o/userinfo/", - api_base_url="https://auth.treehousefullofstars.com/application/o/", - jwks_uri="https://auth.treehousefullofstars.com/application/o/pantry/jwks/", - client_kwargs={'scope': 'openid profile email'}, + name=app.config['OAUTH_NAME'], + client_id=app.config['OAUTH_CLIENT_ID'], + client_secret=app.config['OAUTH_CLIENT_SECRET'], + access_token_url=app.config['OAUTH_ACCESS_TOKEN_URL'], + authorize_url=app.config['OAUTH_AUTHORIZE_URL'], + userinfo_endpoint=app.config['OAUTH_USERINFO_ENDPOINT'], + api_base_url=app.config['OAUTH_API_BASE_URL'], + jwks_uri=app.config['OAUTH_JWKS_URI'], + client_kwargs=app.config['OAUTH_CLIENT_KWARGS'], ) assets = Environment(app) -app.secret_key = '11gs22h2h1a4h6ah8e413a45' +app.secret_key = app.config['APP_SECRET'] app.register_blueprint(access_api.access_api, url_prefix="/access") app.register_blueprint(administration_api.admin_api, url_prefix='/administration') app.register_blueprint(items_API.items_api, url_prefix='/items')