我刚开始在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 = environ [' SERVER_NAME']
KeyError:' SERVER_NAME'
为什么?
答案 0 :(得分:0)
.cgi
文件必须保留,如Flask文档中所述。
也许你可以参考这个 -
https://medium.com/@mohdejazsiddiqui/deploy-flask-app-in-apache-shared-hosting-5b3c82c8fd5e