Note that there are some explanatory texts on larger screens.

plurals
  1. POpython on apache - getting 404
    text
    copied!<p><b>I edited this question after i found a solution... i need to understand why the solution worked instead of my method?</b></p> <p>This is likely to be a silly question. I tried searching other questions that are related... but to no avail.</p> <p><i>i am running Apache/2.2.11 (Ubuntu) DAV/2 SVN/1.5.4 PHP/5.2.6-3ubuntu4.5 with Suhosin-Patch mod_python/3.3.1 Python/2.6.2</i></p> <p>i have a script called test.py</p> <pre><code>#! /usr/bin/python print "Content-Type: text/html" # HTML is following print # blank line, end of headers print "hello world" </code></pre> <p>running it as an executable works...</p> <pre><code>/var/www$ ./test.py Content-Type: text/html hello world </code></pre> <p>when i run <a href="http://localhost/test.py" rel="nofollow noreferrer">http://localhost/test.py</a> i get a 404 error. </p> <p>What am i missing?</p> <p>i used this resource to enable python parsing on apache. <a href="http://ubuntuforums.org/showthread.php?t=91101" rel="nofollow noreferrer">http://ubuntuforums.org/showthread.php?t=91101</a></p> <p>From that same thread... the following code worked.. <B>why?</b> #!/usr/bin/python</p> <pre><code>import sys import time def index(req): # Following line causes error to be sent to browser # rather than to log file (great for debug!) sys.stderr = sys.stdout #print "Content-type: text/html\n" #print """ blah1 = """&lt;html&gt; &lt;head&gt;&lt;title&gt;A page from Python&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;h4&gt;This page is generated by a Python script!&lt;/h4&gt; The current date and time is """ now = time.gmtime() displaytime = time.strftime("%A %d %B %Y, %X",now) #print displaytime, blah1 += displaytime #print """ blah1 += """ &lt;hr&gt; Well House Consultants demonstration &lt;/body&gt; &lt;/html&gt; """ return blah1 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload