diff --git a/flask-40mins.html b/flask-40mins.html index 75d83b5..a5345de 100644 --- a/flask-40mins.html +++ b/flask-40mins.html @@ -162,10 +162,17 @@ │   ├── layout.html │   └── page_not_found.html ├── contents -│   └── 2017-10-31.md ├── setup.py +├── wsgi.py ├── MANIFEST.in └── requirements.txt + +
@@ -275,6 +282,21 @@ projeto Python.
+ +
+

├── wsgi.py

+ +

+ Execução do projeto em modo wsgi. +

+ + +
@@ -576,146 +598,256 @@ STORAGE='/home/jbiason/src/ata/contents' </body> </html> - -
- -
-

templates

-

index.html

- -
{% extends "layout.html" %}
-	{% block maincontent %}
-		<div class='entry'>
-			{% for entry, text in data %}
-			<a href="{{ url_for('show_entry', entry_name=entry) }}">{{ entry }}</a>
-				{{ text|safe }}
-			{% endfor %}
-		</div>
-	{% endblock %}
- - -
- -
-

templates

-

entry.html

- -
{% extends "layout.html" %}
-	{% block maincontent %}
-		<div class="entry">
-			<div class="title">{{ entry }}</div>
-			{{ output|safe }}
-		</div>
-	{% endblock %}
- - -
- -
-

templates

-

page_not_found.html

- -
{% extends "layout.html" %}
-	{% block maincontent %}
-		<h2>Page not found</h2>
-	{% endblock %}
- - -
- -
-

templates

-

entry_not_found.html

- -
{% extends "layout.html" %}
-	{% block maincontent %}
-		<h2>Entry not found</h2>
-	{% endblock %}
- - -
- - -
-
-

setup.py

- -
from setuptools import setup
+                        
+                    
+ +
+

templates

+

index.html

+ +
{% extends "layout.html" %}
+    {% block maincontent %}
+        <div class='entry'>
+            {% for entry, text in data %}
+            <a href="{{ url_for('show_entry', entry_name=entry) }}">{{ entry }}</a>
+                {{ text|safe }}
+            {% endfor %}
+        </div>
+    {% endblock %}
+ + +
+ +
+

templates

+

entry.html

+ +
{% extends "layout.html" %}
+    {% block maincontent %}
+        <div class="entry">
+            <div class="title">{{ entry }}</div>
+            {{ output|safe }}
+        </div>
+    {% endblock %}
+ + +
+ +
+

templates

+

page_not_found.html

+ +
{% extends "layout.html" %}
+    {% block maincontent %}
+        <h2>Page not found</h2>
+    {% endblock %}
+ + +
+ +
+

templates

+

entry_not_found.html

+ +
{% extends "layout.html" %}
+    {% block maincontent %}
+        <h2>Entry not found</h2>
+    {% endblock %}
+ + +
+
+ +
+
+

setup.py

+ +
from setuptools import setup
 
 with open('requirements.txt') as origin:
     requirements = origin.readlines()
 
-setup(name='Ata',
+setup(name='ata',
       version='0.1',
       long_description='A Flask app',
       packages=['ata'],
       zip_safe=False,
       include_package_data=True,
       install_requires=requirements)
-
-
+ + + + + +
+
+

wsgi.py

+ +
from ata.main import app as application
+ + +
+

MANIFEST.in

recursive-include ata/templates *
-recursive-include ata/static *
+recursive-include ata/static * +include requirements.txt
+ +
-
-
-

Rodando

-

(Dev server)

+
+
+

Rodando

+

(Dev server)

-

+                        

 FLASK_APP=ata/main.py flask run
-						
+
-

-export FLASK_RUN=ata/main
+                        

+export FLASK_APP=ata/main
 flask run
-						
-
-
+ + + +
+
-
-
-

Rodando de verdade

-

Dependências de sistema

+
+
+

Rodando de verdade

+

Dependências de sistema

-
sudo dnf install nginx uwsgi
+
sudo dnf install nginx uwsgi uwsgi-plugin-python3
-
sudo yum install nginx uwsgi
+
sudo yum install nginx uwsgi uwsgi-plugin-python3
-
sudo apt-get install nginx uwsgi
-
-
+ +
+ +
+

Rodando de verdade

+

Virtualenv (primeira vez)

+ +
mkdir -p /usr/local/venv
+mkdir -p /usr/local/apps
+python -m venv /usr/local/venv/ata
+ + +
+ +
+

Rodando de verdade

+

Instalando novas versões

+ +
tar xzf Ata-0.1.tar.gz --one-top-level=/usr/local/apps/
+ln -sf /usr/local/apps/Ata-0.1 /usr/local/apps/ata
+source /usr/local/venv/ata/bin/activate
+python3 -m pip install -U -r /usrlocal/apps/ata/requirements.txt
+ + +
+ +
+

Rodando de verdade

+

Primeira configuração uwsgi

+ +

/etc/uwsgi.d/ata.ini

+ +
[uwsgi]
+chdir=/usr/local/apps/ata
+module=wsgi
+plugins=python3
+virtualenv=/usr/local/venv/ata
+uid=uwsgi
+gid=uwsgi
+processes=4
+socket=/var/run/uwsgi/ata.sock
+
+