3

我正在尝试这样做:

@get("/admin/questions/:question_id")
def question (question_id):
    pass
    #Some code for returning the question

@put("/admin/questions/:question_id")
    pass
    #I intend to write some code to update the question here.

这可能吗?GET 和 POST 确实有效,但 PUT 显然不起作用。

4

3 回答 3

5

是的,你可以这样做。请参阅文档:

例子:

from bottle import put, run

@put("/foo")
def foo():
    return "Foo"

run()
于 2012-08-07T11:48:48.900 回答
3

我发现了这个:https ://myadventuresincoding.wordpress.com/2011/01/02/creating-a-rest-api-in-python-using-bottle-and-mongodb/ 。它可能有用。

于 2012-08-07T11:44:16.963 回答
1

我也有同样的问题。上面的链接很有帮助。我还发现这些网页很有用:

http://gotofritz.net/blog/weekly-challenge/restful-python-api-bottle/(周末代码战士在一页中创建宁静的界面 - 这对我来说很清楚)

http://www.marginhound.com/bottle-py-resources/ http://isbullsh.it/2011/11/Python-micro-frameworks/ http://publish.luisrei.com/articles/flaskrest.html

一旦我花时间浏览了这些页面,它就非常容易实现。

于 2013-02-16T19:37:24.373 回答