简体   繁体   English

我可以在Python Bottle中使用PUT http方法吗?

[英]Can I use PUT http method with Python Bottle?

I'm trying to do this: 我正在尝试这样做:

@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.

Is this possible? 这可能吗? GET and POST do work, PUT is apparently not working. GET和POST确实有效,PUT显然不起作用。

Yes, you can do this. 是的,你可以这样做。 See the documentation: 查看文档:

Example: 例:

from bottle import put, run

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

run()

I've had the same question. 我有同样的问题。 The above links were helpful. 以上链接很有帮助。 I also found these webpages useful: 我还发现这些网页很有用:

http://gotofritz.net/blog/weekly-challenge/restful-python-api-bottle/ (weekend code warrior creates restful interface in one page - this made it very clear for me) 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 http://www.marginhound.com/bottle-py-resources/ http://isbullsh.it/2011/11/Python-micro-frameworks/ http://publish.luisrei.com/articles/flaskrest.html

Once I took the time to go through these pages, it was surprisingly easy to implement. 一旦我花时间浏览这些页面,就可以轻松实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM