带Flask的Python CGI无法正常工作 [英] Python CGI with flask not working
问题描述
我刚刚开始在Godaddy入门包上共享托管.我按照此处的说明使用FLASK设置CGI: http://flask.pocoo.org/docs/deploying/cgi/ >
但是当我运行cgi.py时,出现此错误:
Traceback(最近一次通话最近):运行中的文件"/home/railwayapi/python/lib/python3.4/wsgiref/handlers.py",第137行self.result =应用程序(self.environ,self.start_response)在__call__中的文件"/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py"中,第1836行返回self.wsgi_app(环境,start_response)wsgi_app中的文件"/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py",行1812ctx = self.request_context(环境)在request_context中,文件"/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py"第1773行返回RequestContext(self,environ)__init__中的第224行的文件"/home/railwayapi/flasker/lib/python3.4/site-packages/flask/ctx.py"self.url_adapter = app.create_url_adapter(self.request)在create_url_adapter中,文件"/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py",行1602server_name = self.config ['SERVER_NAME'])在bind_to_environ中的文件"/home/railwayapi/flasker/lib/python3.4/site-packages/werkzeug/routing.py",行1165server_name =环境['SERVER_NAME']KeyError:"SERVER_NAME"状态:500内部服务器错误内容类型:文本/纯文本内容长度:59
这是主要部分:server_name = environ ['SERVER_NAME']
KeyError:"SERVER_NAME"
为什么?
必须保存Flask文档中提到的 .cgi
文件.
也许您可以参考这个-
https://medium.com/@ mohdejazsiddiqui/deploy-flask-app-in-apache-shared-hosting-5b3c82c8fd5e
I have just started shared hosting on godaddy starter pack. I followed the instructions here to set up CGI with FLASK: http://flask.pocoo.org/docs/deploying/cgi/
But when i run the cgi.py then i get this error:
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
This is the main part: server_name = environ['SERVER_NAME']
KeyError: 'SERVER_NAME'
Why?
The .cgi
file has to remain as it is mentioned in the Flask documentation.
Maybe you can refer to this -
https://medium.com/@mohdejazsiddiqui/deploy-flask-app-in-apache-shared-hosting-5b3c82c8fd5e
这篇关于带Flask的Python CGI无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!