【问题标题】:Can Python Bottle and CGI (or fastCGI) on IIS 7.5 be used for Production?IIS 7.5 上的 Python Bottle 和 CGI​​(或 fastCGI)可以用于生产吗?
【发布时间】:2015-04-10 16:24:31
【问题描述】:

我正在使用 Bottle 并从命令提示符(内置服务器)运行它。当我部署它时,我没有看到文档中提到 IIS:

http://bottlepy.org/docs/dev/deployment.html

我知道它并不是真正考虑到 IIS,但微软有一篇文章:

https://support.microsoft.com/kb/276494?wa=wsignin1.0

考虑到这一切,Bottle 能否在 IIS 7.5 上运行 - 用于生产

我在 SO 和其他地方看到了一些关于 fastCGI 和 Python 的问题,但我不知道这是否适用于生产。

注意,我不想使用 IronPython。除了 Python 解释器,我想尽可能多地使用原生的 MS IIS(我必须这样做)。

【问题讨论】:

    标签: python cgi iis-7.5 fastcgi bottle


    【解决方案1】:

    我的经验是使用 Apache(在 Linux 和 Windows 上)。您参考的文章给出了 ActiveState Python 的示例(顺便说一下,这是我在 Windows 上使用的)并且适用于运行 Python cgi 脚本而不是 fastcgi。所以如果你想在 IIS 下运行 fastcgi(假设 fastcgi 是 IIS 的一个选项),你将不得不在别处寻找如何做到这一点。

    但要回答您的问题:是的,因为 IIS 确实支持 Python cgi 脚本,您可以确保在该模式下运行您的 Bottle 应用程序。例如:

    from bottle import Bottle
    app = Bottle()
    
    app.route('/')
    def hello():
       return 'Hello!'
    
    app.run(server='cgi')
    

    如果你找到了为 fastcgi 配置 IIS 的方法,那么我建议你安装 flup 然后代码:

    from bottle import Bottle
    app = Bottle()
    
    app.route('/')
    def hello():
       return 'Hello!'
    
    from flup.server.fcgi import WSGIServer
    WSGIServer(app).run()
    

    无论如何,以上两个示例分别在 Apache 下用于 cgi 和 fastcgi。我可能会指出,在 apache 下运行 cgi 时,我的输出在 Windows 上被截断。这是否会成为 IIS 下的问题,您会发现。见Truncated output using Python bottle 0.12.8 as a CGI application under Windows on an Apache server

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-24
      • 2015-03-26
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      • 2011-04-11
      • 1970-01-01
      相关资源
      最近更新 更多