I have found why it didn't work -- the web.py is not used correctly,and the browse to the web page is also wrong.
first, I arranged the file like below:
folder1
--GetText.html
--cgi-bin
--TextAnalysis.py
and accessed the web page by just clicking the file GetText.html. the error happended.
I reviewed some pages about web.py and jQuery,such as random Bytes, even a forum's source code used web.py and jQuery on github, realized the /template
folder is not unnecessary.
Now I rearrange the files like this
folder1
--TextAnalysis.py
--templates
--GetText.html
thus jquery.post() in GetText.html
is changed to
jQuery.ajax({
type: 'POST',
url: "/TextPickup",
data: postdata,
success: function(data){alert(data);},
dataType:'text'
});
in TextAnalysis.py
:
class Index:
def GET(self):
return render.GetText()
...
render = web.template.render('templates/') #add up
now I visist the web page by typing url http://127.0.0.1/
in firefox, and all works fine.