I am following the guide at https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04 to setup my NGINX / UWSGI / FLASK application however it only documents the instructions on getting the application to work when navigating to root (/). So far everything is working how the tutorial describes, but how do I get this working for additional routes such as /tool/project. If I try to add /tool/project location to nginx config using the same parameters as root, it doesn't work and just returns a 404. What am I missing?
I have a symlink in /usr/share/html/nginx/tools to the templates folder of which contains index.html of project
user@vm:/usr/share/nginx/html/tools$ ls -l
total 0
lrwxrwxrwx 1 root root 47 Sep 23 14:32 project -> /home/username/git/project/templates/
My NGINX config /etc/nginx/sites-enabled/project:
server {
listen 80;
server_name 192.168.0.x;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/username/git/project/project.sock;
}
location /tools/project/ {
include uwsgi_params;
uwsgi_pass unix:/home/username/git/project/project.sock;
}
}
WSGI config for project:
[Unit]
Description=uWSGI instance to serve project
After=network.target
[Service]
User=username
Group=www-data
WorkingDirectory=/home/username/git/project
Environment="PATH=/home/username/git/project/env/bin"
ExecStart=/home/username/git/project/env/bin/uwsgi --ini project.ini
[Install]
WantedBy=multi-user.target
Flask Code:
app = Flask(__name__, static_url_path='',
static_folder='/usr/share/nginx/html/'
)
resource = '/usr/share/nginx/html/Common/custom/template/v1.0.0'
##############################################################################
@app.route("/")
def build_form() -> Response:
return render_template('index.html')
##############################################################################
if __name__ == "__main__":
app.run(host='0.0.0.0')
~