试着让烧杯会话在python瓶架中与gunicorn一起工作

2024-06-06 07:14:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用瓶子来编写一个小的web程序,并将以下源文件命名为index.py。我也在程序中使用烧杯会话库。当我使用python index.py运行代码时,一切正常。但当我使用gunicorn -c gunicorn.conf index:app时,我会收到这样的错误消息,说烧杯密钥{}不存在。如何更改代码以使程序在gunicorn服务器中重新工作?在

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/bottle-0.12.7-py2.7.egg/EGG-INFO/scripts/bottle.py", line 857, in _handle
    self.trigger_hook('before_request')
  File "/Library/Python/2.7/site-packages/bottle-0.12.7-py2.7.egg/EGG-INFO/scripts/bottle.py", line 640, in trigger_hook
    return [hook(*args, **kwargs) for hook in self._hooks[__name][:]]
  File "/Users/yizeng/Documents/python_projects/simple-courses/index.py", line 17, in setup_request
    request.session = request.environ['beaker.session']
KeyError: 'beaker.session'

index.py的源代码:

^{pr2}$

Tags: 代码inpy程序bottleindexrequestsession
1条回答
网友
1楼 · 发布于 2024-06-06 07:14:18

我相信您根本不需要最后一个块if __name...。Gunicorn以WSIG的身份运行索引模块的应用程序“varibale”意味着它应该启动瓶子应用程序的实例。在

相关问题 更多 >