recipes_api.uploadImage updated to new schema
This commit is contained in:
parent
3407273959
commit
f82168c712
Binary file not shown.
@ -227,17 +227,26 @@ def postSKUItem():
|
|||||||
return jsonify({'recipe': recipe, 'error': True, 'message': f'method {request.method} is not allowed!'})
|
return jsonify({'recipe': recipe, 'error': True, 'message': f'method {request.method} is not allowed!'})
|
||||||
|
|
||||||
@recipes_api.route('/recipe/postImage/<recipe_id>', methods=["POST"])
|
@recipes_api.route('/recipe/postImage/<recipe_id>', methods=["POST"])
|
||||||
|
@login_required
|
||||||
def uploadImage(recipe_id):
|
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 = request.files['file']
|
||||||
file_path = current_app.config['UPLOAD_FOLDER'] + f"/recipes/{file.filename.replace(" ", "_")}"
|
file_path = current_app.config['UPLOAD_FOLDER'] + f"/recipes/{file.filename.replace(" ", "_")}"
|
||||||
file.save(file_path)
|
file.save(file_path)
|
||||||
|
|
||||||
database_config = config()
|
|
||||||
site_name = session['selected_site']
|
site_name = session['selected_site']
|
||||||
with psycopg2.connect(**database_config) as conn:
|
database_recipes.postRecipeUpdate(site_name, {'id': recipe_id, 'update': {'picture_path': file.filename.replace(" ", "_")}})
|
||||||
postsqldb.RecipesTable.updateRecipe(conn, site_name, {'id': recipe_id, 'update': {'picture_path': file.filename.replace(" ", "_")}})
|
return jsonify({'error': False, 'message': 'Recipe was updated successfully!'})
|
||||||
|
|
||||||
return jsonify({})
|
|
||||||
|
|
||||||
@recipes_api.route('/recipe/getImage/<recipe_id>')
|
@recipes_api.route('/recipe/getImage/<recipe_id>')
|
||||||
def get_image(recipe_id):
|
def get_image(recipe_id):
|
||||||
|
|||||||
16
static/pictures/recipes/docker-compose.yml
Normal file
16
static/pictures/recipes/docker-compose.yml
Normal file
@ -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
|
||||||
Loading…
x
Reference in New Issue
Block a user