Flask app with virtual Python environment in Unit 1.1 ?
Valentin V. Bartenev
vbart at nginx.com
Sun Apr 29 15:06:51 UTC 2018
On Sunday, 29 April 2018 17:10:08 MSK Ralph Seichter wrote:
[..]
> Here's my minimal wsgi.py:
>
> # /var/www/myapp/wsgi.py
> import mypackage
> if __name__ == "__main__":
> mypackage.run()
>
> The Flask application object is defined in mypackage.__init__.py:
>
> app = Flask(__name__)
>
> NGINX Unit does not know about the virtual Python environment at this
> time, and I don't know how I can set the required library paths. Can
> somebody please point me in the right direction?
>
[..]
You can set a path to Python virtual environment using the "home"
parameter of application object.
"myapp": {
"type": "python",
"module": "wsgi",
"user": "nginx",
"group": "nginx",
"path": "/var/www/myapp",
"home": "/path/to/your/venv/directory"
}
Please also note that your application callable need to be named
"application" (not "app"). That can be easily achievable by:
application = app
in your wsgi.py
wbr, Valentin V. Bartenev
More information about the nginx
mailing list