1
@delete路線休息我有一個非常簡單的CRUD API:瓶:當我進口SQLAlchemy的
from bottle import get, post, put, delete, run
@get('/items/')
@get('/items')
def item_list():
return "LIST"
@get('/items/<upc>')
def item_show(upc="0000"):
return "SHOW ITEM WITH UPC " + upc
@delete('/items/<upc>')
def item_delete(upc="0000"):
return "DELETE ITEM WITH UPC " + upc
@put('/items/<upc>')
def item_save(upc="0000"):
return "SAVE ITEM WITH UPC " + upc
@post('/items/<upc>')
def item_create(upc="0000"):
return "CREATE ITEM WITH UPC " + upc
run()
這工作得很好,我可以運行服務器和打所有的端點和得到正確的字符串後面。但是,如果我補充一下:
from sqlalchemy import *
頂端,然後,當我嘗試運行服務器我得到這個錯誤:
Traceback (most recent call last):
File "app.py", line 14, in <module>
def item_delete(upc="0000"):
TypeError: 'Delete' object is not callable
我在做什麼錯?
謝謝!當我縮小到只有我使用它時,它工作得很好。 – 2012-08-02 06:09:56