python - 用Flask Python框架重写配置Lighttpd的问题

标签 python configuration rewrite lighttpd flask

我已经使用其内置服务器运行并开发了Flask应用程序,而没有发生任何问题。它运行良好,并且非常流畅有趣。不幸的是,Lighttpd一如既往地难以部署。我正在严格按照说明进行操作,但不幸的是,我的应用程序仍无法正常工作。

到目前为止,这是我的配置:

server.modules   += ( "mod_fastcgi" )
server.modules   += ( "mod_rewrite" )

fastcgi.server = ("/bioinfo/main.fcgi" =>
    ((
        "socket" => "/tmp/bioinfo-fcgi.sock",
        "bin-path" => "/var/www/bioinfo/main.fcgi",
        "check-local" => "disable",
        "max-procs" => 1
    ))
)
fastcgi.debug = 1

url.rewrite-once = (
    "^/bioinfo/static/(.*)$" => "/bioinfo/static/$1",
    "^/bioinfo/(.*)$" => "/bioinfo/main.fcgi/$1"
)

# in: /etc/lighttpd/conf-available/10-fastcgi.conf


这样可以显示主页,但不显示任何后续页面。

我的Flask应用程序中有几个app.route处理程序,可以使用客户端中的某些XHR使用GET或POST访问。

另外,这是我的.fcgi文件,只是为了确保我在这里没有任何明显的错误:

#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from main import app

if __name__ == '__main__':
    WSGIServer(app).run()


如果有人能确定问题所在,那么AJAX不适用于该应用程序的URI(很可能是因为我的重写规则很奇怪),对此我将非常感激。预先感谢大家。

最佳答案

您需要chdir到应用程序手动运行的目录。

关于python - 用Flask Python框架重写配置Lighttpd的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6024100/

相关文章:

java - Eclipse 运行配置

php - 重写YouTube网址

python - 按特定顺序移动 pandas 数据框中的行

linux - Yocto 中是否有类似于 buildroot 的任何 .config 文件

javascript - 从 flask /python调用Javascript函数

c# - EF 4.3 抛出 "An error occurred while getting provider info from the dB. caused by EF using an incorrect con. string. Check Inner Excptin."

php - .htaccess 替换(重写)PHP URL 中的 $_GET 变量

.htaccess 用查询字符串重写 URL

python - 一次遍历两个大数组

python - 在 Python 的单元测试中比较 XML