daniel__
daniel__

Reputation: 11845

python not executed and code is shown literal in the page

In ubuntu 12.04 i have this basic http server:

python -m SimpleHTTPServer

And this file demo.py

#!/usr/bin/python2.7
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""

However when I open: http: //127.0.0.1:8000/demo.py

i receive a page with the demo.py literal in the browser. Obviously what is expected is hello world.

What is the problem? any idea?

Upvotes: 1

Views: 125

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121834

SimpleHTTPServer can only serve static pages, not CGI scripts. You could use CGIHTTPServer instead.

Use this only for local testing setups; these servers have hardly been battletested on the wider web and are almost certainly not secure.

Upvotes: 2

Related Questions