@route('/locations', method='GET')
def get_location():
entity = db['locations'].find({'coordinate2d': {'$near': [37.871593, -122.272747]}}).limit(3)
if not entity:
abort(404, 'No nearby locations')
return entity
對於上面的代碼部分的響應是:的Python /瓶/ MongoDB的:不支持的響應類型:<type 'dict'>
Error 500: Internal Server Error
Sorry, the requested URL 'http://localhost:8080/locations' caused an error:
Unsupported response type: <type 'dict'>
我怎樣才能抓住,作爲一種類型的瓶從蒙戈信息可以返回作爲JSON ?
您是否嘗試過分解問題,即用簡單的字典文字替換'db.find'調用?如果這樣工作,問題必須與Mongo相關。它不是,它與瓶子有關。 – Helgi 2012-02-23 14:35:19
@Helgi我有,瓶當然與常規字典文字工作。但它不能處理MongoDB ObjectId。 – 2012-02-23 22:46:59