gpt4 book ai didi

python - 按照 Werkzeug 教程 "shortly"后出现错误 111

转载 作者:行者123 更新时间:2023-12-01 05:25:38 26 4
gpt4 key购买 nike

我按照 Werkzeug 教程 "Shortly" here 进行操作

提交有效网址后我收到此错误消息。

Traceback (most recent call last)

File "/home/sadik/NLM/shortly/shortly.py", line 87, in __call__

return self.wsgi_app(environ, start_response)

File "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.9.4-py2.7.egg/werkzeug/wsgi.py", line 579, in __call__

return self.app(environ, start_response)

File "/home/sadik/NLM/shortly/shortly.py", line 83, in wsgi_app

response = self.dispatch_request(request)

File "/home/sadik/NLM/shortly/shortly.py", line 33, in dispatch_request

return getattr(self, 'on_' + endpoint)(request, **values)

File "/home/sadik/NLM/shortly/shortly.py", line 45, in on_new_url

short_id = self.insert_url(url)

File "/home/sadik/NLM/shortly/shortly.py", line 72, in insert_url

short_id = self.redis.get('reverse-url:' + url)

File "/usr/local/lib/python2.7/dist-packages/redis-2.9.1-py2.7.egg/redis/client.py", line 705, in get

return self.execute_command('GET', name)

File "/usr/local/lib/python2.7/dist-packages/redis-2.9.1-py2.7.egg/redis/client.py", line 464, in execute_command

connection.send_command(*args)

File "/usr/local/lib/python2.7/dist-packages/redis-2.9.1-py2.7.egg/redis/connection.py", line 334, in send_command

self.send_packed_command(self.pack_command(*args))

File "/usr/local/lib/python2.7/dist-packages/redis-2.9.1-py2.7.egg/redis/connection.py", line 316, in send_packed_command

self.connect()

File "/usr/local/lib/python2.7/dist-packages/redis-2.9.1-py2.7.egg/redis/connection.py", line 253, in connect

raise ConnectionError(self._error_message(e))

ConnectionError: Error 111 connecting localhost:6379. Connection refused.

错误信息表明 localhost:6379 有问题相关代码部分在这里:

def create_app(redis_host='localhost', redis_port=6379, with_static=True):
app = Shortly({
'redis_host': redis_host,
'redis_port': redis_port
})
if with_static:
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {
'/static': os.path.join(os.path.dirname(__file__), 'static')
})
return app

if __name__ == '__main__':
from werkzeug.serving import run_simple
app = create_app()
run_simple('127.0.0.1', 5000, app, use_debugger=True, use_reloader=True)

这当然意味着服务器正在 localhost:5000 上运行。那么为什么create_app函数中还有另一个端口号呢?这让我有点困惑。

最佳答案

我不熟悉 Short 或 werkzeug,但看起来您缺少 Redis 服务器,请使用您最喜欢的包管理器安装一个,然后重试。

关于python - 按照 Werkzeug 教程 "shortly"后出现错误 111,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21384944/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com