From 4ea131299a6c00ef37325d43b1655546f039a8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique?= Date: Mon, 18 Sep 2023 12:24:05 -0300 Subject: [PATCH] alguns consertos --- FlaskAPI/.idea/.gitignore | 8 ---- FlaskAPI/.idea/FlaskAPI.iml | 19 ---------- .../inspectionProfiles/profiles_settings.xml | 6 --- FlaskAPI/.idea/misc.xml | 4 -- FlaskAPI/.idea/modules.xml | 8 ---- FlaskAPI/.vscode/launch.json | 17 --------- FlaskAPI/.vscode/settings.json | 0 FlaskAPI/Dockerfile | 16 -------- FlaskAPI/__pycache__/app.cpython-310.pyc | Bin 394 -> 0 bytes .../__pycache__/image.cpython-310.pyc | Bin 1333 -> 0 bytes .../__pycache__/status.cpython-310.pyc | Bin 868 -> 0 bytes FlaskAPI/controllers/image.py | 2 +- .../__pycache__/image.cpython-310.pyc | Bin 2120 -> 0 bytes FlaskAPI/services/image.py | 35 ++++++------------ .../__pycache__/image_helper.cpython-310.pyc | Bin 549 -> 0 bytes FlaskAPI/static/image_helper.py | 3 -- scripts/init.py | 4 +- 17 files changed, 14 insertions(+), 108 deletions(-) delete mode 100644 FlaskAPI/.idea/.gitignore delete mode 100644 FlaskAPI/.idea/FlaskAPI.iml delete mode 100644 FlaskAPI/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 FlaskAPI/.idea/misc.xml delete mode 100644 FlaskAPI/.idea/modules.xml delete mode 100644 FlaskAPI/.vscode/launch.json delete mode 100644 FlaskAPI/.vscode/settings.json delete mode 100644 FlaskAPI/__pycache__/app.cpython-310.pyc delete mode 100644 FlaskAPI/controllers/__pycache__/image.cpython-310.pyc delete mode 100644 FlaskAPI/controllers/__pycache__/status.cpython-310.pyc delete mode 100644 FlaskAPI/services/__pycache__/image.cpython-310.pyc delete mode 100644 FlaskAPI/static/__pycache__/image_helper.cpython-310.pyc diff --git a/FlaskAPI/.idea/.gitignore b/FlaskAPI/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/FlaskAPI/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/FlaskAPI/.idea/FlaskAPI.iml b/FlaskAPI/.idea/FlaskAPI.iml deleted file mode 100644 index 15b7777..0000000 --- a/FlaskAPI/.idea/FlaskAPI.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/FlaskAPI/.idea/inspectionProfiles/profiles_settings.xml b/FlaskAPI/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/FlaskAPI/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/FlaskAPI/.idea/misc.xml b/FlaskAPI/.idea/misc.xml deleted file mode 100644 index 4bdfec8..0000000 --- a/FlaskAPI/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/FlaskAPI/.idea/modules.xml b/FlaskAPI/.idea/modules.xml deleted file mode 100644 index 6fa8fc8..0000000 --- a/FlaskAPI/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/FlaskAPI/.vscode/launch.json b/FlaskAPI/.vscode/launch.json deleted file mode 100644 index 6a28b4c..0000000 --- a/FlaskAPI/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "0.0.1", - "configurations": [ - - { - "name": "Python: Flask", - "type": "python", - "request": "launch", - "module": "flask", - "env": { "FLASK_APP": "app.py", "FLASK_DEBUG": "1" }, - "args": ["run", "--no-debugger", "--no-reload"], - "jinja": true, - "justMyCode": true - } - - ] -} diff --git a/FlaskAPI/.vscode/settings.json b/FlaskAPI/.vscode/settings.json deleted file mode 100644 index e69de29..0000000 diff --git a/FlaskAPI/Dockerfile b/FlaskAPI/Dockerfile index b6a5924..b2c6275 100644 --- a/FlaskAPI/Dockerfile +++ b/FlaskAPI/Dockerfile @@ -1,22 +1,11 @@ -# syntax=docker/dockerfile:1 - -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Dockerfile reference guide at -# https://docs.docker.com/engine/reference/builder/ - ARG PYTHON_VERSION=3.10.12 FROM python:${PYTHON_VERSION}-slim as base -# Prevents Python from writing pyc files. ENV PYTHONDONTWRITEBYTECODE=1 - -# Keeps Python from buffering stdout and stderr to avoid situations where -# the application crashes without emitting any logs due to buffering. ENV PYTHONUNBUFFERED=1 WORKDIR /app -# Copy the source code into the container. COPY . . RUN apt-get update && apt-get install -y imagemagick && apt-get install -y wget && ls @@ -30,15 +19,10 @@ RUN wget https://files.ivanch.me/api/public/dl/iFuXSNhw/small-image.png && \ mv big-image.png ./static && \ mv video.mp4 ./static -# Download dependencies as a separate step to take advantage of Docker's caching. -# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. -# Leverage a bind mount to requirements.txt to avoid having to copy them into -# into this layer. RUN --mount=type=cache,target=/root/.cache/pip \ --mount=type=bind,source=requirements.txt,target=requirements.txt \ python -m pip install -r requirements.txt -# Expose the port that the application listens on. EXPOSE 5000 # Run the application. diff --git a/FlaskAPI/__pycache__/app.cpython-310.pyc b/FlaskAPI/__pycache__/app.cpython-310.pyc deleted file mode 100644 index c38168b178e75f1281a8c3bb36648202bc5e1e78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 394 zcmYjNu};G<5Vhl`4WWfniIqJA{Q!gz2nmS=RRWeMl4a_ngxX1TPKM6>0t;I^@=IQs zSoi=YE@5cT^3%I_zIQs8qfyK#KHh)yF=y&U`6{+aB zFg+WlA!op$|Hjh+^mT6;;0X-Y(T0&eSnq+@P-n-&mg(@GCH-%5W(oJm81}e;pnzX~*ss(H%A4zFdUPyVD#6Em(TQMM`bTTiC8cSmU-SpoH+bzkX7P!qJa7PI75G-7>5tF@GBU#Q=XX3#g58WOhqi_n> zNc;qHz?++fg92ys@fs2kvL(i%Uz$#{Z)Ncu9GBUbbbB+>n>yeSm!%~7`uZ@ zzefWMc*#ShL zm^It#a}z(V^06F9^}HBK^t;x7B+Hppea{3+KATJ3nDB|zvwEtf>D(*la;A!DV}gmU zr^ViZ>1a8HY_BM#St{tjZ1-!>qI<(4HxN!R* zjkb)hawz87xRm80YIB;*81HXupzJbprK^ zX<6rxP4h|?Z#ZL%?!6qYoNCn<#@9{WAQ_gaHOkTN7zYJYG&Pt(tt#V;Wn(-_MyrtE zq!muLtw?*j^-EGwwOOeEWBNkH6zbW~cTD|?-ltplZw~*)&-4%^$j#yQ!Dv5M)wZf9 za@6SI!!p-T?`}UHj%rMyE=vk+OPw8<=o<%3yk14KEMgww68850i#>G-;l;{nE2;QR zd&2+vhan8bu>Jc;r2-qUcYMpHdEWen@69rbkm;hDm9j1K7eqhO9JoSl;A64=J>_mO zZfTA4=YyRea;wYurTU!=33T3A=7gB>yq4C+{z0)<(VUU${JGpbBmF799-Z}#@EUPh zLfZA$j40}~ciMY>-D;~yhjfibsTj3Twr_t-<=`6}9%`(eDdo|5^zYa?X$LCI?0{yO z>d=de_8V2t8)>^~^|kdXo6R|?tV-dns)l(fZ&O<}$r`el$NVyngwK0U#Cr)YmsXE| E0fM?laR2}S diff --git a/FlaskAPI/controllers/__pycache__/status.cpython-310.pyc b/FlaskAPI/controllers/__pycache__/status.cpython-310.pyc deleted file mode 100644 index 1eb22a46e7922439bf9b533a18f31fedb246318e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 868 zcmZ`%y>8n;48A-4SW+C<8C&!PJT%#hwn$^NK{^-)+%AHEgKM4}+xkiGq`@9*uXzx^ zNuJ@>Oqn`#>r_&LowP;?kRT}@zmKGfsCMj;fAew96&T;y`u;0$9lrH z=BCJJ)1?hB(n{UvSzg+%DaU1HUJIOtx;C+(venid$o;)5;Qa_btEPPLEO+Wdaof1P|WN}B`}s8`8w zIk_I|Y^aO5nv^E_n2ycj{qQQ8?7>XZ40C$3w1Jefd{#=?A~2f4<*Voa(mUN%9q@GU z1@ZhvH!JZNAa41HZJoix9cFsm`VH8YYwE5E=aIe+F|?spWuE@1|%jYsLh0;W;W=B)|=9in*C5eO+}h6 oU-OAi8andvgx1qVRjU8aW`j4)O5V|rWQbOmMWW;QLC5LvKPCvg1^@s6 diff --git a/FlaskAPI/controllers/image.py b/FlaskAPI/controllers/image.py index 4083088..2a3cad7 100644 --- a/FlaskAPI/controllers/image.py +++ b/FlaskAPI/controllers/image.py @@ -38,4 +38,4 @@ def get_big_image(): @image_blueprint.route('/image/save-big-image', methods=['POST']) def save_image(): - pass + image_service.save_image(request.files.get('file')) diff --git a/FlaskAPI/services/__pycache__/image.cpython-310.pyc b/FlaskAPI/services/__pycache__/image.cpython-310.pyc deleted file mode 100644 index 1ba3a5e6771bfa8460bc807e6150668a73e74344..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2120 zcma)7-D~4U5Z^D^vMf7}FS#U5@1beh;)j|RuJnUaQc|uQ1rs>RQQ;zF@5WK$udI}F zY*tW6UXP>yLGpNiM*j`H_9;(&xQ9Y%OK0TRiIWz(VrO=CX0)?E&5Q=6l0#tp^4D+j z=R6_5qHud~5O!cj?*oxU(k|&yk5VF;BpWu z*x!#J=<$4Y>REj?f)g_~_U7i@fxZbZd&g^{mjH=BKHvSK`F*5x)Rao951V`A_CcU~ zdwOuF+Hur;(hZ`culJrd!RAHSR#7v%U41xC*IR>AA1^Y!upg;mpo3OdVX8)TAU1`E zRjI=SU4aMX$0%oyP1#TE_iC|B%d|oT)63w}hPf~pNINj2$3PVEsDyfvR5GX=F1ZxI zp>|{rxFz$_2A-1z=>X5mB7Au_b+ZzBHoZX`GhjAwjWeqxj9U`$pp6V1C_WLX?tUgr zNd-(&+xNqM82kPfND&4o=w$Ww8TFY(8%uvSuw-qR*d& zhy4!R$KDUSsvq>!6^1=|ILpID!y1Q+2QQSy=snDJUCZee5VQ*<%}rC=D`alNAU^PT z*z0)93$MfdyU>*vbLKsGTZEVj$OxCYR8W^Py8Y*5a{qKSMg<=NVbq{Bf)?3El{vKYD`UC1@aEe2y@@YrpE1}ZMi(tG-|?gMnPZJ gGo-VU$vRo4{kIpU_LtMJzQWEEVOMa8&8v_80Y|{}wg3PC diff --git a/FlaskAPI/services/image.py b/FlaskAPI/services/image.py index 6dea1da..6024378 100644 --- a/FlaskAPI/services/image.py +++ b/FlaskAPI/services/image.py @@ -1,8 +1,5 @@ from wand.image import Image -from static.image_helper import ImageHelper - - def box_blur_image_separable(image, blurred_image, radius_x, radius_y): pixels = image.get_pixels() blurred_pixels = blurred_image.get_pixels() @@ -37,33 +34,23 @@ def save_image(file_stream): file.write(file_stream.read()) file.close() - class ImageService: def __init__(self): pass def box_blur_image(self, img, radius): - temp_path = 'temp_image.png' - img.save(temp_path) - - with Image(filename=temp_path) as img: - img.blur(radius, 2) - blurred_temp_path = 'blurred_temp_image.png' - img.save(filename='blurred_temp_image.png') - return blurred_temp_path - + with Image(filename=img) as image: + image = image.blur(radius, 0) + image = image.blur(0, radius) + return image def get_simple_image(self): - with ImageHelper.SimpleImage as img: - img = ImageHelper.SimpleImage - simple_image = 'simple_image.png' - img.save(filename='simple_image.png') - return simple_image - + with open("./static/small-image.png", "rb") as file: + return file.read() def get_big_image(self): - with ImageHelper.BigImage as img: - img = ImageHelper.BigImage - big_image = 'big_image.png' - img.save(filename='big_image.png') - return big_image + with open("./static/big-image.png", "rb") as file: + return file.read() + + def save_image(self, img): + save_image(img) diff --git a/FlaskAPI/static/__pycache__/image_helper.cpython-310.pyc b/FlaskAPI/static/__pycache__/image_helper.cpython-310.pyc deleted file mode 100644 index f8b5084a0d466eebf641cd9d2b42ad42d652de70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 549 zcmZ`$y-ve05I#FjiJG)4D-%)&`Tz)3K*dj&s#3*bMY61()drHL#HmnO%Y(qk$b0Yv zS(#XP048ilf*{06ce+1+_uV<~blPC#_2mQ42*8^Sn&O$@*r?t&1_4P58R3M$1t3N5 z0npo0P8EIho`3+dDfIkz(+fRP`J+tE)yzgs`NrHcSp}RRaEgR`Mw#+!+%4fPBnFLD zp@X?p=}HyjKWK(E42^1L41#$<#?MgL=*N5xhKKQ$R)vmHp*n~so7qAZ*`&y?)vVO< zc`EhI$z&AkQkKaqPAqe=a5MX>O%ZN>}vxl^MYWs%)Fv19> lUE=a%bGY`MTw>pmE-YVH_!q7Uj%tcvk=b diff --git a/FlaskAPI/static/image_helper.py b/FlaskAPI/static/image_helper.py index 63aba27..55e9c8f 100644 --- a/FlaskAPI/static/image_helper.py +++ b/FlaskAPI/static/image_helper.py @@ -8,10 +8,7 @@ class ImageHelper: @staticmethod def load_images(): ImageHelper.SimpleImage = Image(filename="./static/small-image.png") - #ImageHelper.SimpleImage.save(filename="./static/small-image.png") ImageHelper.BigImage = Image(filename="./static/big-image.png") - #ImageHelper.BigImage.save(filename="./static/big-image.png") - pass ImageHelper.load_images() \ No newline at end of file diff --git a/scripts/init.py b/scripts/init.py index 871b2e8..6347e80 100644 --- a/scripts/init.py +++ b/scripts/init.py @@ -13,5 +13,5 @@ def download_file(url): return local_filename def init(): - download_file('https://files.ivanch.me/api/public/dl/Dj0gkp-m/small-image.png') - download_file('https://files.ivanch.me/api/public/dl/FqHEPM1Q/big-image.png') \ No newline at end of file + download_file('https://files.ivanch.me/api/public/dl/iFuXSNhw/small-image.png') + download_file('https://files.ivanch.me/api/public/dl/81Bkht5C/big-image.png') \ No newline at end of file