Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flask + nginx + uwsgi - Python application not found

cat /etc/nginx/sites-available/mywebsite

server {
     listen              80;

    server_name         mywebsite;

    location /static {
        alias           /var/www/mywebsite/static;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/tmp/website.sock;
        uwsgi_param         UWSGI_PYHOME    /var/www/mywebsite/env;
        uwsgi_param         UWSGI_CHDIR     /var/www/mywebsite;
        uwsgi_param         UWSGI_MODULE    mywebsite;
        uwsgi_param         UWSGI_CALLABLE  mywebsite;
    }

    error_page          404     /404.html;

}

cat /etc/uwsgi/apps-available/website.ini

[uwsgi]
plugins=python
vhost=true
socket=/tmp/website.sock

cat /var/www/mywebsite/mywebsite.py

from flask import Flask
app = Flask(__name__)

@app.route("/")
def index():
    return "It works!"

if __name__ == "__main__":
    app.run()

I'm running nginx, then uwsgi and has uWSGI Error 'Python application not found' in browser.

like image 334
Rigelweb Avatar asked Oct 22 '22 20:10

Rigelweb


1 Answers

I had the same error, in the same configuration, and my problem was simply that the uwsgi service wasn't started. Restarting both nginx and uwsgi solved the problem.

like image 123
Ben G Avatar answered Oct 31 '22 10:10

Ben G