I'm trying to deploy my flask app with lighttpd and fastcgi on a Raspberry Pi. Unfortunately I can not get it to work. Here my procedure:
- I installed lighttpd with
sudo apt install lighttpd - I installed flup with
pip install flup
created /var/www/demoapp/hello.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World"
if __name__ == "__main__":
app.run()
created /var/www/demoapp/hello.fcgi
#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from hello import app
if __name__ == '__main__':
WSGIServer(app).run()
added the follwoing to /etc/lighttpd/lighttpd.conf
fastcgi.server = ("/hello.fcgi" => ((
"socket" => "/tmp/hello-fcgi.sock",
"bin-path" => "/var/www/demoapp/hello.fcgi",
"check-local" => "disable",
"max-procs" => 1
)))
alias.url += (
"/static" => "/var/www/demoapp/static"
)
url.rewrite-once = (
"^(/static($|/.*))$" => "$1",
"^(/.*)$" => "/hello.fcgi$1"
)
To reload the configuration the webserver is restarted with sudo /etc/init.d/lighttpd restart
Then I expect that I can access the app under raspberrypi.local/static I just get a ERR_EMPTY_RESPONSE by Chrome.
Can you spot something that is wrong in my procedure? Did I miss something?
Thanks for your help!