Вопрос

I've installed Flask-Restless and am trying to run the quickstart app. All requests return a 404 error (both in the python logs and in the curl response). My whole setup is:

$ 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/

The console output from run.py is:

 * 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 -

The test.db does get created, and using the debugger I can see that app.run() does execute.

Interestingly, I get exactly the same behavior with Eve. I am able to run simple Flask apps, however.

In case it matters, this is OS X 10.8 and Python 2.7.3.

Это было полезно?

Решение

From the Flask-Restless documentation...

By default, the API for Person, in the above code samples, will be accessible at http://<host>:<port>/api/person, where the person part of the URL is the value of Person.__tablename__:

My guess is that by default, these frameworks do not set up an endpoint on the path /. They only have endpoints defined for paths related to actual objects in your API. Try the following...

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

These URLs might actually hit your endpoints that you're defining.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top