I am installing django for my EC2 instance,
but before I wanted to do this simple test:
i created a file in the instance with the web command line tool
hello.py:
#!/usr/bin/python2.6
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""
and change permissions to execute,
but when I go to my page
http://ec2-107-20-20-19.compute-1.amazonaws.com/hole.py
I see the same as the code, not the actual HTML,
but if i do it in other server i actually she the Hello World! message
so what im I missing in my EC2 instance to be able to see the python files?
where is the cgi folder? how to create it in my root folder?
thanks!
You should use mod_wsgi with Apache 2 or Gunicorn or uWSGI with Nginx (or another web server) to serve Python web applications. Simply putting a
.pyfile somewhere inside your web server’s document root won’t do what you want, since the web server won’t know that it is a script, nor how to execute it (unless you configure CGI appropriately).WSGI has many advantages over CGI: your application code is loaded once and re-used, rather than re-loaded for each web request; it can be run as a different user than the web server, helping to avoid security issues; it has framework support from lots of Python code and frameworks (including Django); etc.
For more on configuring your Django application for WSGI deployment, see the Django deployment docs.