GithubHelp home page GithubHelp logo

abalarin / flask-on-linode Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 28.0 65 KB

Deploying Flask App on Linode

Home Page: http://172.104.28.209/

Python 34.05% JavaScript 0.42% CSS 9.39% HTML 56.15%
python flask linode

flask-on-linode's Issues

Fails in Linode Marketplace on Debian 9 due to incompatible Python and Flask-WTF versions

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:

  • Upgrading python to 3.6. The Linode marketplace suggests this app with Debian 9 only, where python 3.6 doesn't seem to be included out-of-the-box (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?
  • Downgrading Flask-WTF by explicitly requiring 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.