【问题标题】:Can I use PUT http method with Python Bottle?我可以在 Python Bottle 中使用 PUT http 方法吗?
【发布时间】:2013-02-17 03:37:24
【问题描述】:

我正在尝试这样做:

@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 显然不起作用。

【问题讨论】:

    标签: python rest bottle


    【解决方案1】:

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

    例子:

    from bottle import put, run
    
    @put("/foo")
    def foo():
        return "Foo"
    
    run()
    

    【讨论】:

    • 我不太明白这是如何回答这个问题的,因为 OP 已经知道 put 方法。
    【解决方案2】:
    【解决方案3】:

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

    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

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

    【讨论】:

    • 除了marginhound之外所有链接都失效了,它没有提到PUT请求。相关的、最少的代码应该在问题本身中,以使其具有持久的价值。
    猜你喜欢
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 1970-01-01
    • 1970-01-01
    • 2018-11-28
    • 1970-01-01
    相关资源
    最近更新 更多