gpt4 book ai didi

python - "threadsafe cannot be enabled with CGI handler"

转载 作者:行者123 更新时间:2023-11-28 21:22:43 27 4
gpt4 key购买 nike

我遇到了一个看起来很常见的问题。但是,通常建议的解决方案在这里似乎不起作用。尝试运行 App Engine 时出现“无法使用 CGI 处理程序启用线程安全”。当然,文档很糟糕。我正在使用 webapp2,因此线程安全应该无关紧要。

我的文件结构应该是这样的:backend/api/get_json.py - 这为所有到达/api/*.json 的 HTTP 请求提供服务。换句话说,backend/部分对最终用户是隐藏的。

我无法让 app.yaml 识别并正确加载位于/backend/api/get_json.py 的 Python 文件

app.yaml 文件:

application: ebtest
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /api/.*\.json
script: backend/api/get_json.application

libraries:
- name: webapp2
version: "2.5.2"

后端/api/get_json.py

import webapp2

class MainPage(webapp2.RequestHandler):

def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')


application = webapp2.WSGIApplication([
('/api/get_users.json', MainPage),
], debug=True)

错误

  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: **threadsafe cannot be enabled with CGI handler: backend/api/get_json.application**

最佳答案

它对我有用.. 这是我的 app.yaml(我将它与 helloworld 示例结合起来)我在本地主机上启动 dev_appserver 时没有收到任何错误。您使用什么版本的应用程序引擎?我正在使用 1.7.5

application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: true

libraries:
- name: django
version: "1.2"
- name: pycrypto
version: "2.6"


handlers:
- url: /api/.*\.json
script: backend.api.get_json.application
- url: /.*
script: helloworld.app

你需要创造

__init__.py

在后端和 api 文件夹中

关于python - "threadsafe cannot be enabled with CGI handler",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18434983/

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