Difference between revisions of "Flask from command line"
Jump to navigation
Jump to search
(Created page with "Get python flask going on windows: ==Install python and flask, run the first program== <htmltag tagname="video" src="videos/flask_on_windows.mp4" width="400px" controls ></htm...") |
|||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
*You might want to develop your flask programs under Windows or Linux. | |||
*You should run the production service under uWSGI from nginx in Linux. | |||
==Windows: Install python and flask, run the first program== | |||
Get python flask going on windows: | Get python flask going on windows: | ||
==Install python | |||
<htmltag tagname="video" src="videos/ | <htmltag tagname="video" src="videos/flask_from_windows.mp4" width="400px" controls ></htmltag> | ||
==Linux: Install flask, tunnel into debug version== | |||
Get python flask going on a remote linux server: | |||
<htmltag tagname="video" src="videos/flask_on_linux.mp4" width="400px" controls ></htmltag> | |||
==Linux: Running flask for production under uwsgi== | |||
Your service will be more reliable if you run using uwsgi: | |||
Install <code>uwsgi</code> and <code>uwsgi-plugin-python3</code> | |||
sudo apt install uwsgi uwsgi-plugin-python3 | |||
Change <code>/etc/nginx/sites-enabled/tmp.progzoo.net</code> to | |||
server { | |||
server_name tmp.progzoo.net; | |||
location / { | |||
include uwsgi_params; | |||
uwsgi_pass unix:/tmp/project1.sock; | |||
} | |||
location /static { | |||
alias /home/andrew/project1/static; | |||
} | |||
#... stuff generated by certbot | |||
} | |||
#... more stuff generated by certbot | |||
Create the file <code>/etc/uwsgi/apps-enabled/tmp.ini</code> | |||
[uwsgi] | |||
plugins = python3 | |||
pythonpath = /home/andrew/project1/venv/bin | |||
module = wsgi | |||
socket = /tmp/project1.sock | |||
chmod-socket = 775 | |||
chdir = /home/andrew/project1 | |||
virtualenv = venv | |||
master = true | |||
module = server:app | |||
If you change <code>server.py</code> or a template you must restart uwsgi | |||
sudo systemctl restart uwsgi | |||
<htmltag tagname="video" src="videos/uwsgi.mp4" width="400px" controls ></htmltag> |
Latest revision as of 22:10, 18 September 2021
- You might want to develop your flask programs under Windows or Linux.
- You should run the production service under uWSGI from nginx in Linux.
Windows: Install python and flask, run the first program
Get python flask going on windows:
Linux: Install flask, tunnel into debug version
Get python flask going on a remote linux server:
Linux: Running flask for production under uwsgi
Your service will be more reliable if you run using uwsgi:
Install uwsgi
and uwsgi-plugin-python3
sudo apt install uwsgi uwsgi-plugin-python3
Change /etc/nginx/sites-enabled/tmp.progzoo.net
to
server { server_name tmp.progzoo.net; location / { include uwsgi_params; uwsgi_pass unix:/tmp/project1.sock; } location /static { alias /home/andrew/project1/static; } #... stuff generated by certbot } #... more stuff generated by certbot
Create the file /etc/uwsgi/apps-enabled/tmp.ini
[uwsgi] plugins = python3 pythonpath = /home/andrew/project1/venv/bin module = wsgi socket = /tmp/project1.sock chmod-socket = 775 chdir = /home/andrew/project1 virtualenv = venv master = true module = server:app
If you change server.py
or a template you must restart uwsgi
sudo systemctl restart uwsgi