From f82168c71251b35f7864c5d435286c29481c2239 Mon Sep 17 00:00:00 2001 From: Jadowyne Ulve Date: Sat, 26 Apr 2025 19:48:16 -0500 Subject: [PATCH] recipes_api.uploadImage updated to new schema --- .../__pycache__/recipes_api.cpython-312.pyc | Bin 17989 -> 18071 bytes scripts/recipes/recipes_api.py | 21 +++++++++++++----- static/pictures/recipes/docker-compose.yml | 16 +++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 static/pictures/recipes/docker-compose.yml diff --git a/scripts/recipes/__pycache__/recipes_api.cpython-312.pyc b/scripts/recipes/__pycache__/recipes_api.cpython-312.pyc index f2caab953fac34622a93873c7c1b0ac943a0ee4e..e8e41da82f7d41378e417a3127db7461d215c293 100644 GIT binary patch delta 641 zcmX@w!#KT{k?%AwFBbz4wAb-wtTx=pH`#Eqj4daV2jk>iQI*LT4Eu%oK++(P!X^nM zYne*~C(pN(;izG*VMt-GVVt}`O=Oa>x&sqf5d$Mbi712x)WMm;mBKxTX*DB6B$z>y zCs7y3Q7FhSE>TF#Q^?FsOixuv%P&$$oP17P$~ZAEMIkLSC$(51sZyaJvA8%hFI}M| zBUPa&H94~&H9j*1s4GRGATzn7v?w*cAh9H4vNe~iqOL+-Vs5GxLK&9=7-Z&I0gWli z;F{deCCy%(oRONFXf^pZm-OVR!bb97%S#J#@)J{1Qxu9zlao`6(@Jx4Diy)nC$}2g z8M;*|1cB{VC{HX_C@n}yEP<GY#JpD;%9*fQ0Qv16sdyP z9YEq1C&+(bmlrt$`Nb?i0_4^rMUX5v#5tZIrxi^CiaZ6WnFAym7{16b@CZ+?HgONW zBOpG5|Du3KgXbL3UrD#klP2am5$oiZ7IuU#P6P99Mh6 zx9*~0{TBuXR!62g+(I)#FX#te6b`z~9ejZ$xX1-){N^IlASTwCK-RC#C(XH8xaI+w zEWo%bW|0<91buEfLvGv(o_UeUbJYkma{C^4j>a0 iJF&?Vj2u;& zA-WhDQowLE6O3OX4Kpv3VRE9qlsvM)YDS1;Fhd1%Btto)CYRr2EfYKTA`PIpCg0?l zCZ>~B9YjQUN()jFOHzYUlQRoai$I>zWSe}?L`+m4$SiUO5e7h_m<>oMC`|rqA}%x; z$b1SCdj%vK7@lwoP1Z1VpR8=5QqRch%d~;z4u{}%4!MgQa@RSuFLG$FaM_@F!1F>> z#)YiB>sjR&v&ye$)nCl2|G>cD$mGHVq}-T1nLaZxWHWk!cu|brOdlB-?0lHMFfefX zGJR(T8T*Befk$|PQMdI47P0T_=pw(0d4Z1MJ;dP1=q$o~ScKJCoqh8m(;z0+SwQhm zn', 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