0
首先我讀過這樣一個問題: Tornado server: enable CORS requests
我所做的是:CORS在python龍捲風只發送選項要求
class BaseHandler(RequestHandler):
def set_default_headers(self, *args, **kwargs):
self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Headers", "x-requested-with")
self.set_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
而且也是一種選擇方法:
def options(self):
self.set_status(204)
self.finish()
並在我的處理程序中:
class AmirTest(BaseHandler):
def get(self, *args, **kwargs):
self.write('You have requested get method!')
def post(self, *args, **kwargs):
self.write('You have requested post method!')
def put(self, *args, **kwargs):
self.write('You have requested put method!')
def delete(self, *args, **kwargs):
self.write('You have requested delete method!')
這是我的要求:
function del(){
$.rest.put(
"http://xxx.xxx.xxx.xxx:7777/amir_test",
{user: "A",pass: "b"},
function (data) {console.log(data);}
);
}
問題是,當我提出的要求,這個網址,在督察的網絡選項卡中,只有一個選項,沒有PUT請求。我該怎麼辦?
我已經做了,但忘了複製到這裏,問題已更新,但結果相同!現在怎麼辦? –
您的'Access-Control-Allow-Methods'需要包含您支持的所有方法(在這種情況下包括PUT和DELETE) –