我敢肯定,這將是一些痛苦的明顯的字符編碼問題的答案...爲什麼curl會截斷這個查詢字符串?
我使用curl命令行來測試python應用程序中的一些端點。該端點接受經緯度的url參數。沒什麼特別的。我把命令:
curl -v -L http://localhost:5000/pulse/?lat=41.225&lon=-73.1
服務器應答,在冗長的捲曲輸出:
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET /pulse/?lat=41.225 HTTP/1.1
> User-Agent: curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: localhost:5000
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 500 INTERNAL SERVER ERROR
< Content-Type: application/json
< Content-Length: 444
< Server: Werkzeug/0.8.1 Python/2.7.2+
< Date: Wed, 01 Feb 2012 17:06:29 GMT
<
{
"msg": "TypeError: float() argument must be a string or a number",
"flag": 0,
"stack": [
"Traceback (most recent call last):",
" File \"engine.py\", line 139, in dispatch_request",
" return getattr(self, 'action_'+endpoint)(request, **values)",
" File \"engine.py\", line 818, in action_getpulse",
" lon = float(request.args.get('lon'))"
],
"err": 1
* Closing connection #0
}
[1]+ Done
在該轉儲的第二行,很明顯,第二PARAM,lon
,不被髮送。我究竟做錯了什麼?謝謝。
你會考慮重新接受答案嗎?第二個看起來更精確。 – 2016-08-06 17:07:30