Flask app with virtual Python environment in Unit 1.1 ?

Ralph Seichter m16+nginx at monksofcool.net
Sun Apr 29 16:02:47 UTC 2018


On 29.04.18 17:06, Valentin V. Bartenev wrote:

> You can set a path to Python virtual environment using the "home"
> parameter of application object.

Ah, that was the missing piece, thank you.

> Please also note that your application callable need to be named
> "application" (not "app").

Alright, I changed my wsgi.py to this:

  from mypackage import app as application
  if __name__ == "__main__":
      application.run()

My application can now be called via NGINX -> NGINX Unit -> App, which
is exactly what wanted. It also requires certain environment variables
to be set, and I am now wondering how to pass these on? I found the
enhancement request https://github.com/nginx/unit/issues/12 but since
this feature does not seem to be implemented yet, what is the
recommended method to pass env variables to Unit workers?

-Ralph


More information about the nginx mailing list