What's the best way to deploy a Flask app using Jython on Tomcat?

谁说胖子不能爱 提交于 2019-12-18 15:36:10

问题


I successfully deployed the demo web app that comes with Jython. It uses modjy which is a Jython WSGI gateway. I'm now trying to hook modjy to my Flask app. I get a handler not defined error.

The full traceback is here: http://pastie.org/2810227


回答1:


There are two different ways you can specify an application to modjy:

  1. Using the app_import_name mechanism
  2. Using a combination of app_directory/app_filename/app_callable_name

For the first method simply create a file that imports your Flask app object.

from my_flask_app import app as application

Then in your web.xml set the proper init-param:

<init-param>
  <param-name>app_import_name</param-name>
  <param-value>wsgi.application</param-value>
</init-param>

For the second method you can use the modjy convention of defining application.py in the servlet context root with a single handler method that invokes the Flask WSGI app:

def handler(environ, start_response):
    return application.wsgi_app(environ, start_response)


来源:https://stackoverflow.com/questions/8010517/whats-the-best-way-to-deploy-a-flask-app-using-jython-on-tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!