xmlhttprequest で JSON を受信するようにボトルを取得しようとしていますが、405 エラーが発生します
私のボトルスクリプトの一部:
@app.route('/myroute/')
def myroute():
print request.json
xhrをテストするための私の他のスクリプトの一部:
jdata = json.dumps({"foo":"bar"})
urllib2.urlopen("http://location/app/myroute/", jdata)
なぜ私は 405 を受け取っているのですか?
bottlepy error: 127.0.0.1 - - [2012-09-23 23:09:34] "POST /myroute/ HTTP/1.0" 405 911 0.005458
urllib2 error: urllib2.HTTPError: HTTP Error 405: Method Not Allowed
私も次のバリエーションを試しました:
@app.route('/myroute/json:json#[1-9]+#')
def myroute(json):
request.content_type = 'application/json'
print request.json, json
jsonを返すことは問題ではないようです