troubleshooting Question

HTTP/1.1" 405 4 Error

Avatar of nainil
nainilFlag for United States of America asked on
9 Comments1 Solution755 ViewsLast Modified:

I am trying to replicate the source code from

I have the following:
Python 2.7

When I try to execute the below code the Apache access logs say it's an HTTP/1.1" 405 4 Error, however the page output says "None". This is the first time we are trying to use Python code. What are we doing wrong?


import web

urls = (
    '/', 'hello',
	'/terms', 'terms'
app = web.application(urls, globals())

class hello:
    def GET(self):
        return '<form action="terms" method="POST"><textarea name="context" style="width:450px; height:300px;">Inevitably, then, corporations do not restrict themselves merely to the arena of economics. Rather, as John Dewey observed, "politics is the shadow cast on society by big business". Over decades, corporations have worked together to ensure that the choices offered by \'representative democracy\' all represent their greed for maximised profits.\n\nThis is a sensitive task. We do not live in a totalitarian society - the public potentially has enormous power to interfere. The goal, then, is to persuade the public that corporate-sponsored political choice is meaningful, that it makes a difference. The task of politicians at all points of the supposed \'spectrum\' is to appear passionately principled while participating in what is essentially a charade.</textarea><br />JSON callback: <input type="text" name="callback" /><br /><input type="submit" value="Get terms" /></form>'

class terms:
    def POST(self):
		import re
		import simplejson as json
		from topia.termextract import extract
		extractor = extract.TermExtractor()
		#extractor.filter = extract.permissiveFilter
		extractor.filter = extract.DefaultFilter(singleStrengthMinOccur=1)
		def term_compare(x, y):
			if y[1]+y[2]*2 > x[1]+x[2]*2:
				return 1
			elif y[1]==x[1] and y[2]==x[2]:
				return 0
			else: # x<y
				return -1
		input = web.input(callback=None)
		content = input.context.lower()
		content = content.replace(u"\u201c", '"').replace(u"\u201d", '"').replace(u"\u2018", "'").replace(u"\u2019", "'").replace(u"\u2026", "")
		list = sorted(extractor(content), term_compare)
		list = list[:50]
		for i in range(len(list)-1, -1, -1):
			if len(list[i][0]) == 1 or list[i][2] > 2 or (list[i][0].find("http") >= 0) or not'[a-z]', list[i][0]) or'[0-9]', list[i][0]):
				list[i] = list[i][0]
		callback = input.callback
		if callback and re.match('^[a-zA-Z0-9._\[\]]+$', callback):
			return callback + '(' + json.dumps(list, indent=4) + ')'
			return json.dumps(list, indent=4)
		#return json.dumps(list, indent=4)
		#return json.dumps(extractor(i.context).sort(term_compare))

if __name__ == "__main__":

app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros