Deploy Flask on Raspberry Pi with Nginx Deploy Flask on Raspberry Pi with Nginx nginx nginx

Deploy Flask on Raspberry Pi with Nginx


You might running flask on the default port, which is 5000.

Try changing this line:

if __name__ == '__main__':    #app.run()    app.run(port=8000)

or change your supervisord command to:

command = /home/pi/hello/bin/python /home/pi/hello/bin/gunicorn hello:app -b 0.0.0.0:8000


You might want to make sure the default site is disabled. Simply delete the symlink default from sites-enabled.

Also, the default port for Flask is 5000 not 8000, so in your nginx configuration, you need to change the following:

location @gunicorn_proxy {    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_set_header Host $http_host;    proxy_redirect off;    proxy_pass http://127.0.0.1:5000; # Default port}