How do I configure the name of my WSGI application

2019-03-25 17:13发布

My Python web application is called app

# example.py
import flask

app = flask.Flask(__name__.split('.')[0])

and when I attempt to launch it on AWS-EB using

# run.py (set correctly with WSGIPath)
from example import app

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

I get

mod_wsgi (pid=22473): Target WSGI script '/opt/python/current/app/run.py' does not contain WSGI application 'application'.

How to I tell AWS that my application instance is called app?

1条回答
我命由我不由天
2楼-- · 2019-03-25 18:00

mod_wsgi expects variable called application. Try to do something like this

from example import app as application

Note: don't do application.run(). It is not needed.

查看更多
登录 后发表回答