How to deploy Flask application with Nginx and uWSGI?

I am deploying Flask application with Nginx and uWSGI for first time. Nginx will listen to port 8000 and WSGI will listen to 8081. I followed the instructions given in problem statement, but the NGINX fails to start.

Problem statement: Deploy a simple flask application with nginx and uwsgi.

Commands for configuring nginx server as per Problem statement:

  1. sudo vi /etc/nginx/nginx.conf
  2. The I was asked to include /projects/challenge/deploy.config in Virtual Host configs.
  3. sudo service nginx restart

For the code, this is what I did:

# Put your code here
from projects.challenge import app
if __name__ == "__main__":


server {
    listen 8000;
    server_name localhost:8081;

    location / {
        include uwsgi_params;

    location /Hello {
        alias /project/challenges/

The test code given in the question for testing deploy.conf is:

def test_conf_file_contents(self):
        with open('deploy.conf', 'r') as f:
            content =
            assert "location /Hello" in content
            assert "server localhost:8081" in content
            assert "listen 8000" in content

from flask import Flask, request, make_response

app = Flask(__name__)
app.secret_key = "Thisisyoursecret"

# Create a simple endpoint /Hello with return message "Welcome to your flask application"

def hello():
  res=make_response("Welcome to your flask application")
  return res

As per instruction in the question, I included deploy.conf in Virtual Host Configs of nginx.conf file as follows:

        # Virtual Host Configs

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
        include /projects/challenge/deploy.conf



The error is:

user@workspacede6jnv452qg2cr45:/projects/challenge$ sudo service nginx restart
 * Restarting nginx nginx                                                                (fail) 

On going to path etc/nginx and starting:

user@workspacede6jnv452qg2cr45:/etc/nginx$ sudo service nginx restart
 * Restarting nginx nginx

nginx is failing to restart when I include deploy.conf in Virtual configuration of nginx.conf. But it starts when I do not include deploy.conf.

I might be making some obvious mistake, I went through Google and Youtube but could not figure out what to fix. No solution worked. I suspect the deploy.conf file but I have no clue how to fix the issue.

Kindly suggest me what to do.