0

So I've setup my server following this tutorial: http://jronnholm.sysio.se/setup-nginx-and-uwsgi-with-python3-on-ubuntu-14-04/

See: nginx + uwsgi + python3 configuration not working

I managed to get it to work by switching /etc/nginx/sites-available/default with /etc/nginx/sites-available/pythonapp and change the sitename to _.

My /etc/nginx/sites-available/default:

server {
    server_name _;
    error_log  /var/log/nginx/pythonapp.error.log;
    access_log         /var/log/nginx/pythonapp.access.log;
    root /vagrant/site/python/pythonapp;
    location / {
        uwsgi_pass unix:/var/run/uwsgi/app/pythonapp/socket;
        include uwsgi_params;
    }
}

But then when I change the content of webpage.py to this:

print "Content-type: text/html\n\n"
print("lololol");

It ends up returning internal server error when I go to http://localhost:8080.

What did I do wrong?

1 Answer 1

1

The Python code of your webpage.py is invalid. Try running it directly from the command line: python3 webpage.py will show you what is wrong.

Change your webpage.py to:

print("Content-type: text/html\n\n")
print("lololol")

The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105).

Note I've removed the semicolon from the second line because it is not doing anything in your example. Python does not require semi-colons to terminate statements. Semicolons can be used to delimit statements if you wish to put multiple statements on the same line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.