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.
Yes, you can do this. See the documentation:
Example:
from bottle import put, run
@put("/foo")
def foo():
return "Foo"
run()
I found this: https://myadventuresincoding.wordpress.com/2011/01/02/creating-a-rest-api-in-python-using-bottle-and-mongodb/ . It might be useful.
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://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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.