簡體   English   中英

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

[英]Can I use PUT http method with Python 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.

這可能嗎? GET和POST確實有效,PUT顯然不起作用。

是的,你可以這樣做。 查看文檔:

例:

from bottle import put, run

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

run()

我有同樣的問題。 以上鏈接很有幫助。 我還發現這些網頁很有用:

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

一旦我花時間瀏覽這些頁面,就可以輕松實現。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM