I'm trying to deploy a hello flask app to a raspberry pi using lighttpd fastCGI.
I followed the instructions on the http://flask.pocoo.org/docs/0.10/deploying/fastcgi/ to the best of my ability
Here is my flask app (/var/www/demoapp/hello.py)
UPDATE p SET GenreOrder = 1
FROM ProgramGenre p
JOIN Filmlager f ON p.ProgramID = f.ProgramID
JOIN Genre g ON p.GenreID = g.GenreID
WHERE f."Type"= g.GenreTitle;
And here is my .fcgi file (/var/www/demoapp/hello.fcgi)
$scope.initDate = function(){
$scope.date = new Date();
}
$scope.initDate();
And here is what I added to my /etc/lighttpd/lighttpd.conf
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World From Flask Yeh!"
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
I get a 404 Not Found error
By the way what is the /tmp/hello-fcgi.sock where do I get this file
Please help. I'm essentially trying to find a simple way to deploy flask on my raspberry pi web server. I have tried several methods. The fastcgi seemed to be the easiest. If there is an easier way then let me know please.
Thank you
Vincent
答案 0 :(得分:1)
我认为问题在于你的hello.fcgi文件中导入了一个名为yourapplication
的模块,但是你创建的烧瓶应用程序名为hello
。
尝试更改此行:
from yourapplication import app
至
from hello import app
修改:此外 - 在测试时仔细检查您的网址 - 因为您的@app.route
设置为根,您必须在您的网址中包含尾部斜杠,例如:
而不是
答案 1 :(得分:0)
首先,与c_tothe_k说的一样,您需要在yourapplication
文件中将hello
更改为hello.fcgi
。
我发现烧瓶文件中的说明缺乏。它建议阅读此页面,我也是http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModFastCGI#Troubleshooting
页面底部有一个示例lighttpd.conf
我遵循了Flask文档和上一页中的说明。我将.fcgi
文件重命名为.py
,如Lightty文档中所示。
如果您遵循此方法,则无需担心.sock文件。这是lighttpd使用UNIX套接字与FastCGI进程通信的旧方法。它只需要在这里,所以配置解析器不会被破坏。
我在lighttpd.conf中使用了以下内容。你的其他文件看起来不错。
(注意,这会将您的应用置于/hello
之下,而不是/
。)
fastcgi.server = (
"/hello" =>
(
"python-fcgi" =>
(
"socket" => "/tmp/fastcgi.python.socket",
"bin-path" => "/var/www/demoapp/hello.py",
"check-local" => "disable",
"max-procs" => 1,
)
)
)