Python2.7 flask uwsgi nginx configuration cannot find unable to load app 0

I have a server of Tencent Cloud. I use flask,uwsgi,nginx to build a server.
is written like this according to the method on the Internet.
my nginx configuration is
I modified this file / etc/nginx/sites-enabled/default

server {
    listen 80;
    server_name 111.230.140.182;
    charset utf-8;
    client_max_body_size 75M;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:8080;
        uwsgi_param UWSGI_PYTHON /usr/bin/python;
        uwsgi_param UWSGI_CHDIR /home/ubuntu/project/test;
        uwsgi_param UWSGI_SCRIPT test:app ;
    }
}

then my uwsgi.ini configuration is written like this:

[uwsgi]
socket = 127.0.0.1:8080
plugins = python
chidir = /home/ubuntu/project/test
wsgi-file = /home/ubuntu/project/test/test.py
callable = app                      -sharp 
protocol=http
module=test
processes = 4
threads = 2

then my test.py is written like this:

from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
    return "<h1> hello world! </h1>"
if __name__ =="__main__":
    app.run(debug=True)

I first run nginx, and then run uwsgi, but I report this error:

mapped 332288 bytes (324 KB) for 8 cores
Operational MODE: preforking+threaded
unable to load app 0 (mountpoint="") (callable not found or import error)
unable to find "application" callable in file / home/ubuntu/project/test/test.py
unable to load app 0 (mountpoint="") (callable not found or import error)

)

I also checked a lot of articles that didn"t solve my problem. Come here for advice!
Thank you!

Mar.04,2021

[uwsgi]
socket = 127.0.0.1:3031
chdir = /home/foobar/myproject/
wsgi-file = myproject/wsgi.py
processes = 4
threads = 2
stats = 127.0.0.1:9191

above is the content of official document .
if you compare your uwsgi.ini configuration file, there are two differences.
the first obvious error

chidir = /home/ubuntu/project/test -sharp  chdir chidir
wsgi-file = /home/ubuntu/project/test/test.py -sharp 

should be changed to

chdir = /home/ubuntu/project/test -sharp  chdir chidir
wsgi-file = test.py -sharp 

the second place is

socket = 127.0.0.1:8080
Change

to

stats = 127.0.0.1:8080

I modified it like this, first of all, I modified the configuration file of nginx.
as for the reason for this change, it is not clear, that is, I read other people's posts and then tried to modify them, at least verifying that they can be used

server {
    listen 80;
    server_name 111.230.140.182;
    charset utf-8;
    client_max_body_size 75M;
    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:8080;
        -sharpuwsgi_param UWSGI_PYTHON /usr/bin/python;  //
        -sharpuwsgi_param UWSGI_CHDIR /home/ubuntu/project/test;  //
        -sharpuwsgi_param UWSGI_SCRIPT test:app ;  //
    }
}

then change the configuration file of uwsgi to:

[uwsgi]
socket=127.0.0.1:8080
plugins = python
wsgi-file=test.py
master=true
processes=4
threads=2
callable=app
stats=127.0.0.1:9191

look at the modification from above, remove the chdir, and then add the master=true, to retain the socket while adding a stats.
after running nginx and uwsgi, you can enter the ip address in the browser and jump directly to the hello world interface.

< hr > < hr >

to talk about the pain in the balls, the configuration file above is new.ini tapped by my own hand. I had the same content on the previous uwsgi.ini file, but I reported an error and couldn't find app. I have found that this uwsgi file is copy directly from the Internet. There are a lot of spaces in front of the line "callable=app". You can't see it. There may be special characters or something. Delete the space and OK it.
this is a pit, so you'd better knock it yourself from now on.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf0f02-1427a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf0f02-1427a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?