{"id":15076,"date":"2024-08-29T11:06:19","date_gmt":"2024-08-29T09:06:19","guid":{"rendered":"https:\/\/www.beseit.net\/?p=15076"},"modified":"2024-08-29T18:02:15","modified_gmt":"2024-08-29T16:02:15","slug":"repassant-i-verificant-tots-els-passos-i-scrips-involucratsamb-el-projecte-hello-flask","status":"publish","type":"post","link":"http:\/\/www.beseit.net\/?p=15076","title":{"rendered":"Aplicaci\u00f3  web &#8220;Hello, Flask!&#8221;. Guia"},"content":{"rendered":"\n<p><a href=\"http:\/\/81.0.60.36:8080\/\" target=\"_blank\" rel=\"noreferrer noopener\">HELLO, FLASK<\/a><\/p>\n\n\n\n<p>Quan combines <mark style=\"background-color:rgba(0, 0, 0, 0);color:#f31c1c\" class=\"has-inline-color\">Flask<\/mark> amb <mark style=\"background-color:rgba(0, 0, 0, 0);color:#f11010\" class=\"has-inline-color\">Gunicorn<\/mark> en un <mark style=\"background-color:rgba(0, 0, 0, 0);color:#f80f0f\" class=\"has-inline-color\">entorn virtual<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#ee0e0e\" class=\"has-inline-color\">est\u00e0s creant una aplicaci\u00f3 web<\/mark> que pot gestionar m\u00faltiples peticions de manera eficient, cosa que \u00e9s essencial per a aplicacions en producci\u00f3. Aix\u00f2 implica configurar el servidor, gestionar les depend\u00e8ncies i assegurar-te que l\u2019aplicaci\u00f3 funcioni correctament en un entorn controlat.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Crear un Entorn Virtual<\/h3>\n\n\n\n<p><strong>Comen\u00e7a creant un entorn virtual per a la teva aplicaci\u00f3.<\/strong> Aix\u00f2 a\u00eflla les depend\u00e8ncies de la teva aplicaci\u00f3 del sistema global de Python.<\/p>\n\n\n\n<p>python3 -m venv \/volume2\/web\/0-python\/<mark style=\"background-color:rgba(0, 0, 0, 0);color:#f70808\" class=\"has-inline-color\">ent_virt_mut<\/mark>\/<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"74\" src=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-26.png\" alt=\"\" class=\"wp-image-15097\" srcset=\"http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-26.png 709w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-26-300x31.png 300w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-26-500x52.png 500w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2. Activar l&#8217;Entorn Virtual<\/h3>\n\n\n\n<p><strong>Activa l&#8217;entorn virtual.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Instal\u00b7lar les Depend\u00e8ncies<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Linux\/MacOS:<\/strong> source \/volume2\/web\/0-python\/ent_virt_mut\/bin\/<mark style=\"background-color:rgba(0, 0, 0, 0);color:#f40808\" class=\"has-inline-color\">activate<\/mark><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"855\" height=\"38\" src=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-27.png\" alt=\"\" class=\"wp-image-15102\" style=\"width:1328px;height:auto\" srcset=\"http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-27.png 855w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-27-300x13.png 300w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-27-768x34.png 768w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-27-500x22.png 500w\" sizes=\"auto, (max-width: 855px) 100vw, 855px\" \/><\/figure>\n\n\n\n<p>3. Instal\u00b7lar dependenci\u00e8ncies <\/p>\n\n\n\n<p><strong>Instal\u00b7la Flask i <code>gunicorn<\/code> dins de l&#8217;entorn virtual.<\/strong><\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0);color:#e91212\" class=\"has-inline-color\">pip install flask gunicorn<\/mark><\/p>\n\n\n\n<p>(ent_virt_mut2) urqtejmi@synology_vall:\/volume2\/web\/0-python$ pip install flask gunicorn<br>Collecting flask<br>Using cached flask-3.0.3-py3-none-any.whl (101 kB)<br>Collecting gunicorn<br>Downloading gunicorn-23.0.0-py3-none-any.whl (85 kB)<br>\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 85.0\/85.0 KB 406.6 kB\/s eta 0:00:00<br>Collecting importlib-metadata&gt;=3.6.0<br>Using cached importlib_metadata-8.4.0-py3-none-any.whl (26 kB)<br>Collecting Jinja2&gt;=3.1.2<br>Using cached jinja2-3.1.4-py3-none-any.whl (133 kB)<br>Collecting Werkzeug&gt;=3.0.0<br>Using cached werkzeug-3.0.4-py3-none-any.whl (227 kB)<br>Collecting itsdangerous&gt;=2.1.2<br>Using cached itsdangerous-2.2.0-py3-none-any.whl (16 kB)<br>Collecting blinker&gt;=1.6.2<br>Using cached blinker-1.8.2-py3-none-any.whl (9.5 kB)<br>Collecting click&gt;=8.1.3<br>Using cached click-8.1.7-py3-none-any.whl (97 kB)<br>Collecting packaging<br>Downloading packaging-24.1-py3-none-any.whl (53 kB)<br>\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 54.0\/54.0 KB 490.7 kB\/s eta 0:00:00<br>Collecting zipp&gt;=0.5<br>Using cached zipp-3.20.1-py3-none-any.whl (9.0 kB)<br>Collecting MarkupSafe&gt;=2.0<br>Using cached MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (26 kB)<br>Installing collected packages: zipp, packaging, MarkupSafe, itsdangerous, click, blinker, Werkzeug, Jinja2, importlib-metadata, gunicorn, flask<br>Successfully installed Jinja2-3.1.4 MarkupSafe-2.1.5 Werkzeug-3.0.4 blinker-1.8.2 click-8.1.7 flask-3.0.3 gunicorn-23.0.0 importlib-metadata-8.4.0 itsdangerous-2.2.0 packaging-24.1 zipp-3.20.1<br>WARNING: You are using pip version 22.0.4; however, version 24.2 is available.<br>You should consider upgrading via the &#8216;\/volume2\/web\/0-python\/ent_virt_mut2\/bin\/python3 -m pip install &#8211;upgrade pip&#8217; command.<br>(ent_virt_mut2) urqtejmi@synology_vall:\/volume2\/web\/0-python$<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0);color:#da1515\" class=\"has-inline-color\">Per actualitzar <code>pip<\/code> a la versi\u00f3 m\u00e9s recent, pots fer-ho amb la seg\u00fcent comanda:<\/mark><\/p>\n\n\n\n<p><strong>\/volume2\/web\/0-python\/ent_virt_mut\/bin\/python3 -m pip install &#8211;upgrade pip<\/strong><\/p>\n\n\n\n<p><strong>4. Instalar les llibreries Necess\u00e0ries:<\/strong> pip install flask<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"795\" height=\"222\" src=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-29.png\" alt=\"\" class=\"wp-image-15107\" srcset=\"http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-29.png 795w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-29-300x84.png 300w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-29-768x214.png 768w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-29-500x140.png 500w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/figure>\n\n\n\n<p>5. Desactivar l&#8217;Entorn Virtual: deactivate<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"765\" height=\"183\" src=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-30.png\" alt=\"\" class=\"wp-image-15109\" srcset=\"http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-30.png 765w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-30-300x72.png 300w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-30-500x120.png 500w\" sizes=\"auto, (max-width: 765px) 100vw, 765px\" \/><\/figure>\n\n\n\n<p><strong>Verifica que l&#8217;entorn virtual s&#8217;ha creat correctament<\/strong>: ls \/volume2\/web\/0-python\/ent_virt_mut2<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"144\" src=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-31.png\" alt=\"\" class=\"wp-image-15111\" srcset=\"http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-31.png 749w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-31-300x58.png 300w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-31-500x96.png 500w\" sizes=\"auto, (max-width: 749px) 100vw, 749px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"56\" src=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-32.png\" alt=\"\" class=\"wp-image-15113\" srcset=\"http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-32.png 825w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-32-300x20.png 300w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-32-768x52.png 768w, http:\/\/www.beseit.net\/wp-content\/uploads\/2024\/08\/imatge-32-500x34.png 500w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/figure>\n\n\n\n<p>urqtejmi@synology_vall:\/volume2\/web\/0-python$ ls \/volume2\/web\/0-python\/ent_virt_mut2 on hi ha els fitxers o directoris<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">: bin, include, lib, lib64, pyvenv.cfg<\/mark><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HELLO, FLASK Quan combines Flask amb Gunicorn en un entorn virtual, est\u00e0s creant una aplicaci\u00f3 web que pot gestionar m\u00faltiples peticions de manera eficient, cosa que \u00e9s essencial per a aplicacions en producci\u00f3. Aix\u00f2 implica configurar el servidor, gestionar les &hellip; <a href=\"http:\/\/www.beseit.net\/?p=15076\">Continua llegint <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":8179,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[171],"tags":[],"class_list":["post-15076","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/15076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15076"}],"version-history":[{"count":28,"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/15076\/revisions"}],"predecessor-version":[{"id":15116,"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/15076\/revisions\/15116"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/media\/8179"}],"wp:attachment":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15076"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}