0
即時通訊編寫一個簡單的前端網頁,將採取一串單詞,並返回一個單詞表count。現在,我可以查詢字符串並將結果發佈到同一頁面上。不過,我想重定向並與應@Post(/「結果」)蟒蛇瓶框架後重定向
下面是我的代碼,但是,它不斷給我一個錯誤說張貼另一頁結果:異常:
AttributeError ("'NoneType' object has no attribute 'split'",)
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/bottle.py", line 862, in _handle
return route.call(**args)
File "/Library/Python/2.7/site-packages/bottle.py", line 1729, in wrapper
rv = callback(*a, **ka)
File "frontEnd.py", line 16, in result
File "frontEnd.py", line 23, in query
for word in keyString.split():
AttributeError: 'NoneType' object has no attribute 'split'
我應該更改什麼,以便將結果表發佈到重定向的頁面/結果而不會導致錯誤?
@get('/')
def search():
return '''<h1>Search</h1><form action="/" method="post"> Keyword:<input name="keywords"type="text"/><input value="GO" type="submit" /> </form>'''
@post('/')
def do_search():
redirect('/result')
@post('/result')
def result(wc,keyString):
keyString = request.forms.get('keywords')
wc = query(keyString)
return wordCountHTML(wc,keyString)