bustleandflurry/bottle-api-json-formatting — pull request #7 by edersohe (2013-10-08 20:40:19+00:00)
Title: support for dumps BSON objects into response

from bottle import Bottle, run
from bottle_api_json_formatting import JsonFormatting
from pymongo import MongoClient

app = Bottle()
app.install(JsonFormatting())

db = MongoClient().test_database

db.users.insert({'username': 'user1', 'first_name': 'User', 'last_name': 'One' })
db.users.insert({'username': 'user2', 'first_name': 'User', 'last_name': 'Two' })

@app.get('/users')
def index():
return db.users.find()

if __name__ == '__main__':
run(app, host='0.0.0.0', port=8080, debug=True)