diff --git a/scripts/recipes/__pycache__/recipes_api.cpython-312.pyc b/scripts/recipes/__pycache__/recipes_api.cpython-312.pyc index f2caab9..e8e41da 100644 Binary files a/scripts/recipes/__pycache__/recipes_api.cpython-312.pyc and b/scripts/recipes/__pycache__/recipes_api.cpython-312.pyc differ diff --git a/scripts/recipes/recipes_api.py b/scripts/recipes/recipes_api.py index ad39ce5..06e78c0 100644 --- a/scripts/recipes/recipes_api.py +++ b/scripts/recipes/recipes_api.py @@ -227,17 +227,26 @@ def postSKUItem(): return jsonify({'recipe': recipe, 'error': True, 'message': f'method {request.method} is not allowed!'}) @recipes_api.route('/recipe/postImage/', methods=["POST"]) +@login_required def uploadImage(recipe_id): + """ post an image for a recipe into the database and files by passing the recipe_id and picture_path + --- + parameters: + - name: recipe_id + in: path + required: true + schema: + type: integer + responses: + 200: + description: image uploaded succesfully! + """ file = request.files['file'] file_path = current_app.config['UPLOAD_FOLDER'] + f"/recipes/{file.filename.replace(" ", "_")}" file.save(file_path) - - database_config = config() site_name = session['selected_site'] - with psycopg2.connect(**database_config) as conn: - postsqldb.RecipesTable.updateRecipe(conn, site_name, {'id': recipe_id, 'update': {'picture_path': file.filename.replace(" ", "_")}}) - - return jsonify({}) + database_recipes.postRecipeUpdate(site_name, {'id': recipe_id, 'update': {'picture_path': file.filename.replace(" ", "_")}}) + return jsonify({'error': False, 'message': 'Recipe was updated successfully!'}) @recipes_api.route('/recipe/getImage/') def get_image(recipe_id): diff --git a/static/pictures/recipes/docker-compose.yml b/static/pictures/recipes/docker-compose.yml new file mode 100644 index 0000000..5ee77f6 --- /dev/null +++ b/static/pictures/recipes/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.4' +services: + speedtest-tracker: + container_name: speedtest-tracker + ports: + - 8080:80 + - 8443:443 + environment: + - PUID=1000 + - PGID=1000 + - DB_CONNECTION=sqlite + volumes: + - ./data:/config + - ./keys:/config/keys + image: lscr.io/linuxserver/speedtest-tracker:latest + restart: unless-stopped