gpt4 book ai didi

python - FastCGI、Lighttpd 和 Flask

转载 作者:太空狗 更新时间:2023-10-29 19:29:56 24 4
gpt4 key购买 nike

我正在我的 Raspberry Pi 上设置一个简单的网络服务器,但我似乎无法正确设置 lighttpd、fastcgi 和 flask。

到目前为止,我已经经历了几次 /etc/lighttpd/lighttpd.conf 的迭代,最近的一次是

fastcgi.server = ("/test" =>
"test" => (
"socket" => "/tmp/test-fcgi.sock",
"bin-path" => "/var/www/py/test.fcgi",
"check-local" => "disable"
)
)

/etc/init.d/lighttpd start 上出现错误。第一行看起来不对,所以我在粗箭头后面加了一组括号:

fastcgi.server = ("/test" => (
...
))

这并没有吐出错误,但是当我尝试连接时,我在 Chrome 中得到了 ERR_CONNECTION_REFUSED。然后我尝试删除 "/test"=>,但出现了同样的问题。我还尝试了 this question, 中显示的配置并且出现了同样的问题。

/var/www/py/test.fgci 中:

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

WSGIServer(app, bindAddress="/tmp/test-fcgi.sock").run()

/var/www/py/test.py 中:

from flask import Flask
app = Flask(__name__)

@app.route("/test")
def hello():
return "<h1 style='color:red'>&#9773; hello, comrade &#9773;</h1>"

当我用 /etc/init.d/lighttpd start 启动时,当前的 lighttpd.conf 失败。

最佳答案

我无法在 Python 部分真正帮助您,因为它超出了我的技能范围,但是当将 php 作为 fcgi 服务器运行时,我会像下面这样使用 lighttpd.conf。

fastcgi.server += ( ".php" =>
((
"host" => "127.0.0.1",
"port" => "9000",
"broken-scriptfilename" => "enable"
))
)

所以我假设像下面这样的东西是你需要的 python。

fastcgi.server += ( "/test" =>
((
"socket" => "/tmp/test-fcgi.sock",
"bin-path" => "/var/www/py/test.fcgi",
"check-local" => "disable"
))
)

关于python - FastCGI、Lighttpd 和 Flask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36272196/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com