내가 지금처럼 jQuery를 Ajax 호출이 있습니다 플라스크를 만드는 방법/Ajax HTTP 연결을 활성 상태로 유지 하시겠습니까?
$("#tags").keyup(function(event) {
$.ajax({url: "/terms",
type: "POST",
contentType: "application/json",
data: JSON.stringify({"prefix": $("#tags").val() }),
dataType: "json",
success: function(response) { display_terms(response.terms); },
});
나는 플라스크 방법과 같이이 있습니다, 그러나 플라스크를
POST /terms HTTP/1.1
Host: 127.0.0.1:5000
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/json; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://127.0.0.1:5000/
Content-Length: 27
Pragma: no-cache
Cache-Control: no-cache
{"prefix":"foo"}
:
@app.route("/terms", methods=["POST"])
def terms_by_prefix():
req = flask.request.json
tlist = terms.find_by_prefix(req["prefix"])
return flask.jsonify({'terms': tlist})
tcpdump와는 HTTP 대화 상자를 보여줍니다 keep-alive없이 응답합니다.
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 445
Server: Werkzeug/0.8.3 Python/2.7.2+
Date: Wed, 09 May 2012 17:55:04 GMT
{"terms": [...]}
실제로 keep-alive가 구현되지 않았습니까?
실제로 통합 웹 서버는 개발 용도로만 사용됩니다. – ThiefMaster
어제 분명히 피곤했습니다. 나는 1.0 답장을 가지고 있다는 것을 알지 못했다. :/나는 한 번 봐야 할 일이 무엇인지 볼 것입니다. 고마워. – Bittrance