【发布时间】:2013-12-05 19:21:59
【问题描述】:
我正在处理一个简短的 Flask tutorial 并且遇到了一些问题。我走到了尽头,收到了 500 服务器错误。如果我从我的虚拟环境中运行 .fcgi,我会收到以下消息。我没有在我有权访问的日志中看到任何错误。不太确定是什么问题。
- 共享主机:Bluehost
- Python 版本:2.7.6
错误信息
(flask_hello_world) me@domain [~/public_html/projects/flask_hello_world]# python flask_hello_world.fcgi
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 12
Hello World!
.htaccess
Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %(REQUEST_FILENAME) !-f
RewriteRule ^(.*)$ flask_hello_world.fcgi/$1 [QSA,L]
RewriteLog rewrite.log
RewriteLogLevel 3
flask_hello_world.fcgi
#!/path/to/python27/.virtenv/flask_hello_world/bin/python
from flup.server.fcgi import WSGIServer
from flask_hello_world_app import app as application
if __name__ == '__main__':
WSGIServer(application).run()
flask_hello_world_app.py
from datetime import datetime
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@app.route('/the-time')
def the_time():
cur_time = str(datetime.now())
return cur_time + ' is the current time! ...YEAH!'
if __name__ == '__main__':
app.run()
安装在/.virtenv/flask_hello_world上的软件包
# pip list
Flask (0.10.1)
flup (1.0.2)
itsdangerous (0.23)
Jinja2 (2.7.1)
MarkupSafe (0.18)
pip (1.4.1)
setuptools (0.9.8)
Werkzeug (0.9.4)
wsgiref (0.1.2)
【问题讨论】:
-
所以说没有安装flup?你检查过是不是这样吗?即 ssh 进入您的会话并尝试
python import flup? -
抱歉,我一开始还以为是我的问题,所以更改了标题以反映新问题。
-
您在哪里输入服务器连接信息?抱歉,我对 Flask 不是很熟悉,但这似乎是它正在寻找的信息。您是否准确地完成了教程中列出的所有内容?也许重新开始,看看它是否能解决它?
-
我做到了。在创建 3 个文件后的教程中,一切正常。
-
您确定无法获得更详尽的错误日志吗?你读过this page吗?
标签: python .htaccess flask virtualenv flup