gpt4 book ai didi

带 flask 的 Python CGI 不起作用

转载 作者:行者123 更新时间:2023-12-03 17:04:01 25 4
gpt4 key购买 nike

我刚刚开始在 Godaddy 入门包上共享托管。
我按照此处的说明使用 FLASK 设置 CGI:
http://flask.pocoo.org/docs/deploying/cgi/

但是当我运行 cgi.py 然后我得到这个错误:

Traceback (most recent call last):
File "/home/railwayapi/python/lib/python3.4/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1812, in wsgi_app
ctx = self.request_context(environ)
File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1773, in request_context
return RequestContext(self, environ)
File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/ctx.py", line 224, in __init__
self.url_adapter = app.create_url_adapter(self.request)
File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1602, in create_url_adapter
server_name=self.config['SERVER_NAME'])
File "/home/railwayapi/flasker/lib/python3.4/site-packages/werkzeug/routing.py", line 1165, in bind_to_environ
server_name = environ['SERVER_NAME']
KeyError: 'SERVER_NAME'
Status: 500 Internal Server Error
Content-Type: text/plain
Content-Length: 59

这是主要部分:
server_name = 环境['SERVER_NAME']

KeyError: 'SERVER_NAME'



为什么?

最佳答案

.cgi文件必须保留,因为它在 Flask 文档中提到。

也许你可以引用这个——

https://medium.com/@mohdejazsiddiqui/deploy-flask-app-in-apache-shared-hosting-5b3c82c8fd5e

关于带 flask 的 Python CGI 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25138090/

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