平凡的Flask不宁应用程序上的HTTP 404错误

平凡的Flask不宁应用程序上的HTTP 404错误,flask,flask-restless,Flask,Flask Restless,我已安装并正在尝试运行。所有请求都返回404错误(在python日志和curl响应中)。我的整个设置是: $ virtualenv venv --distribute $ source venv/bin/activate $ pip install flask-restless $ pip install flask-sqlalchemy # it doesn't appear to do this automatically ... Copy code from quickstart to "

我已安装并正在尝试运行。所有请求都返回404错误(在python日志和curl响应中)。我的整个设置是:

$ virtualenv venv --distribute
$ source venv/bin/activate
$ pip install flask-restless
$ pip install flask-sqlalchemy # it doesn't appear to do this automatically
... Copy code from quickstart to "run.py" ...
$ python ./run.py

(another window)
$ curl -i http://127.0.0.1:5000/
run.py的控制台输出为:

 * Running on http://127.0.0.1:5000/
 * Restarting with reloader
127.0.0.1 - - [16/Apr/2013 17:08:05] "GET / HTTP/1.1" 404 -
确实创建了
test.db
,使用调试器,我可以看到
app.run()
确实执行

有趣的是,我的行为和你的完全一样。不过,我可以运行简单的烧瓶应用程序

如果有必要的话,这是OS X 10.8和Python 2.7.3。

来自Flask Untivent

默认情况下,上述代码示例中Person的API将 可在http://:/api/person访问,其中person部分 URL的值是
个人的值。\uuuu tablename\uuuu

我的猜测是,默认情况下,这些框架不会在路径
/
上设置端点。它们只为API中与实际对象相关的路径定义了端点。试试下面的

curl -i http://127.0.0.1:5000/api/person
curl -i http://127.0.0.1:5000/person

这些URL实际上可能会命中您正在定义的端点。

特别是
curlhttp://127.0.0.1:5000/api/person
(这有点令人惊讶;我不知道它会小写)。我假设root将提供某种Django风格的“这是API”;这真是帮了大忙。Eve的问题还在继续,但这意味着这是Eve的问题,而不是我的一般设置。当我研究文档时,小写来自Flask SQLAlchemy,它将
CamelCase
更改为
camel\u case
[略微无关]小心url\u前缀和_tablename。我花了三个小时试图弄清楚这一点。如果你有一个模型人物,例如:
Person\u blueprint=manager.create\u api\u blueprint(Person,methods=['GET','POST','DELETE'],url\u prefix=“/api”)
你的url应该像
http://localhost:5000/api/person
在我的例子中,我这样创建了一个蓝图
person\u blueprint=manager.create\u api\u blueprint(person,methods=['GET','POST','DELETE'],url\u prefix=“/person”)
错误的url\u前缀给我带来了很多痛苦。