在Tomcat上使用Jython部署Flask应用程序的最佳方式是什么? [英] What's the best way to deploy a Flask app using Jython on Tomcat?

查看:591
本文介绍了在Tomcat上使用Jython部署Flask应用程序的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功部署了Jython附带的演示Web应用程序。它使用了一个Jython WSGI网关的modjy。我现在正在尝试将modjy挂接到我的Flask应用程序。我得到一个处理程序未定义的错误。



完整的追溯在这里: http://pastie.org/2810227

解决方案

有两种不同的方法可以指定一个应用程序modjy :
$ b $ ol

  • 使用app_import_name机制

  • 使用app_directory / app_filename / app_callable_name
  • >

    对于第一种方法,简单地创建一个导入Flask应用程序对象的文件。

    从my_flask_app导入应用程序作为应用程序

    然后在您的web.xml设置正确的init-param:

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

    对于第二种方法,您可以使用在servlet上下文根中定义application.py的modjy约定调用Flask WSGI应用程序的单个处理程序方法:
    $ b $ pre $ $ $ c $ def处理程序(environ,start_response):
    返回应用程序。 wsgi_app(environ,start_response)


    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

    解决方案

    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)
    

    这篇关于在Tomcat上使用Jython部署Flask应用程序的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆