#現状
最近bottleに取り組み始めました。
公式などを見ながらgetでの値の受取りを試しているのですが、どうもうまく動作しません。
python
1from bottle import route,run,template,get,post,request,static_file,response,os,SimpleTemplate,view 2import bottle 3 4@route('/hello') 5def hello(): 6 return "hello" 7 8@route('/hello2',method="GET") 9def hello2(): 10 x=request.forms.get("input") 11 return "受け取りました→" + x
以上のようなコードで、
http://localhost:8000/hello
にアクセスすると、正常にhelloが表示されます。
しかし、hello2のほうで、うまくgetが受け取れません。
URL http://localhost:8000/hello2?input=abc 結果 Error: 500 Internal Server Error Sorry, the requested URL 'http://localhost:8000/hello2?input=abc' caused an error: Internal Server Error Exception: TypeError('must be str, not NoneType',) Traceback: Traceback (most recent call last): File "-----bottle.py", line 997, in _handle out = route.call(**args) File "-----bottle.py", line 1998, in wrapper rv = callback(*a, **ka) File "index.py", line 30, in hello2 return "受け取りました→" + x TypeError: must be str, not NoneType (-----は隠しています)
#質問
公式などを見てその通りにやっているつもりなのですが、うまくいきません。
どこがおかしいのでしょうか。
非常に初歩的なミスかもしれませんが、ご指導お願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/03/21 02:13
2018/03/21 02:23