[2.4.3/Newbie] Web script doesn't run

Gilles nospam at nospam.com
Mon Feb 11 10:30:01 CET 2013


Hello

	I have a couple of newbie questions about using Python in a FastCGI
+ Flup context on a shared CentOS server:

1. The following script runs fine...
=========================
#!/usr/bin/env python2.6

def myapp(environ, start_response):
	start_response('200 OK', [('Content-Type', 'text/plain')])
	return ['Done!\n']

if __name__ == '__main__':
	from flup.server.fcgi import WSGIServer
	WSGIServer(myapp).run()
=========================

... while this triggers an error:
=========================
#!/usr/bin/env python2.6
# -*- coding: UTF-8 -*-

from cgi import escape
import sys, os

def app(environ, start_response):
	start_response('200 OK', [('Content-Type', 'text/html')])
	
	yield '<h1>FastCGI Environment</h1>'
	yield '<table>'
	for k, v in sorted(environ.items()):
	     yield '<tr><th>%s</th><td>%s</td></tr>' % (escape(k),
escape(v))
	yield '</table>'

if __name__ == '__main__':
	from flup.server.fcgi import WSGIServer
	WSGIServer(app).run()
=========================

"Internal Server Error: The server encountered an internal error or
misconfiguration and was unable to complete your request. [...]
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request."

2. Generally speaking, what is the right way to investigate an error
in a Python web script? FWIW I have access to the shared server
through SSH.

Thank you.



More information about the Python-list mailing list