[英]Flask HTTPie Connection refused
So I am testing my web service with HTTpie and I am trying to issue a GET request with the following 因此,我正在使用HTTpie测试我的Web服务,并且尝试使用以下命令发出GET请求
http --json --auth <ADMIN_EMAIL>:<PASSWORD> GET http://127.0.0.1:5000/api/v1.0/posts
Removed actual email and password to post here 删除了要在此处发布的实际电子邮件和密码
@api.route('/posts/')
def get_posts():
page = request.args.get('page', 1, type=int)
pagination = Post.query.paginate(
page, per_page=current_app.config['POSTS_PER_PAGE'],
error_out=False)
posts = pagination.items
prev = None
if pagination.has_prev:
prev = url_for('api.get_posts', page=page-1, _external=True)
next = None
if pagination.has_next:
next = url_for('api.get_posts', page=page+1, _external=True)
return jsonify({
'posts': [post.to_json() for post in posts],
'prev': prev,
'next': next,
'count': pagination.total
})
api is a blueprint api是一个蓝图
And I am getting the following error 我收到以下错误
http: error: ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))
Going to http://
127.0.0.1/api/v.10/posts` in a browser does work, but it's not clear what's different between the browser and httpie. 在浏览器中进入
http://
127.0.0.1 / api / v.10 / posts`确实可行,但尚不清楚浏览器和httpie之间的区别。
好的,我的virtualenv使用的是python 2.7,通过将其升级到python 3.4,它似乎可以解决问题并成功连接!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.