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

mar*_*cho 3 python rest bottle

我正在尝试这样做:

@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.
Run Code Online (Sandbox Code Playgroud)

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

小智 5

是的,你可以这样做.查看文档:

例:

from bottle import put, run

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

run()
Run Code Online (Sandbox Code Playgroud)