我有一个非常简单的 CRUD API:
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
我究竟做错了什么?