Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Run Flask on Twisted web server, WSGI application error

I'm new to flask. I want to deploy my flask application on prod, so for that I want to use Twisted web server (on windows). Below is my proj structure and I'm using Blueprints: enter image description here

my run.py file is as below:

#!/usr/bin/env python

from ProjName import app

if __name__ == '__main__':
    app.run()

command I'm trying is :

twistd web --wsgi run.app

In top most init.py I'm just doing :

app = Flask(__name__)

And rest code is related to registering blueprints.

What changes do I need to make in my files so as to run on twisted web? Or do I need to completely restructure my code?

PS: I know my question may not be clear. I've referred some links but it is just confusing me. Appreciate your help!

like image 363
gB08 Avatar asked Oct 04 '17 12:10

gB08


1 Answers

You haven't put the root of your source tree into Python's import path so the module name "run" can't be resolved. Fix it by setting PYTHONPATH (for example):

export PYTHONPATH=${PYTHONPATH}:${PWD}
twistd web --wsgi run.app
like image 151
Jean-Paul Calderone Avatar answered Oct 21 '22 06:10

Jean-Paul Calderone