abalarin / flask-on-linode Goto Github PK
View Code? Open in Web Editor NEWDeploying Flask App on Linode
Home Page: http://172.104.28.209/
Deploying Flask App on Linode
Home Page: http://172.104.28.209/
Hoping this is the right place to mention this (I could not find Flask-on-Linode on https://github.com/linode/Marketplace-Apps, for example)
I've had some trouble diagnosing 502s I get out of the box when installing through Linode Marketplace, although it comes with the correct configuration as described here.
After much confusion I realised the reason is the flask server is constantly getting restarted after failing with:
$ cat /var/log/flask_app/flask_app.err.log
SyntaxError: invalid syntax
[2021-07-24 23:42:51 +0000] [19401] [INFO] Worker exiting (pid: 19401)
/usr/local/lib/python3.5/dist-packages/flask_sqlalchemy/__init__.py:873: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
[2021-07-24 23:42:51 +0000] [19402] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 557, in spawn_worker
worker.init_process()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 136, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 384, in import_app
__import__(module)
File "/home/flask_app_project/flask_app/__init__.py", line 14, in <module>
from flask_app import routes
File "/home/flask_app_project/flask_app/routes.py", line 7, in <module>
from flask_app.forms import PostForm
File "/home/flask_app_project/flask_app/forms.py", line 1, in <module>
from flask_wtf import FlaskForm
File "/usr/local/lib/python3.5/dist-packages/flask_wtf/__init__.py", line 1, in <module>
from .csrf import CSRFProtect, CsrfProtect
File "/usr/local/lib/python3.5/dist-packages/flask_wtf/csrf.py", line 220
dest = f'{view.__module__}.{view.__name__}'
The reason is that the installed version of Flask-WTF uses f-syntax for strings (f'Here's the value of {something}'
), which came in in Python 3.6.
$ pip freeze | grep WTF
Flask-WTF==0.15.0
WTForms==2.3.3
$ python3 --version
Python 3.5.3
0.15 has officially dropped support for 3.5 (wtforms/flask-wtf#416) and the very next release (0.15.1) adds a python_requires to disallow installation on 3.5: https://flask-wtf.readthedocs.io/en/0.15.x/changes/#version-0-15-1
Possible fixes would be:
apt-cache search python3 | grep 3.6
shows no results). I'm not sure where this is set up for the standard server that comes up via Linode Marketplace?Flask-WTF<0.15.0
in requirements.txt (I've tested this and it works)On an entirely separate note, may I suggest an addition to the otherwise great deployment notes on allowing incoming TCP traffic from ufw
via something like ufw allow from <your-ip> to <linode-ip> proto tcp port 80
? This is not entirely obvious to noobs like me.
Thanks for the nice example app and detailed explanation on setting it up.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.