【发布时间】:2017-06-28 14:39:28
【问题描述】:
我在 localhost (http://localhost:5000) 中使用 Flash 并尝试使用 python 请求从 elasticsearch 请求 json 结果
这是我的代码
@app.route('/test')
def TestElasticsearch():
url = "http://localhost:9200/customer/_search?q=James&size=5"
r = requests.get(url)
print r
return r.text
当我通过谷歌浏览器访问http://localhost:5000/test时,它返回
ConnectionError: HTTPConnectionPool(host='localhost', port=9200): Max retries exceeded with url: /customer/_search?q=James&size=5 (Caused by <class 'socket.error'>: [Errno 111] Connection refused)
请注意,我已尝试通过 google chrome 访问 http://localhost:9200/customer/_search?q=James&size=5,它可以正常工作。
请帮我解决问题
【问题讨论】:
-
尝试使用 127.0.0.1 而不是 localhost。
标签: python elasticsearch localhost