我正在尝试返回我的帖子,但我得到了
TypeError:'Cursor' 对象不可调用。
我该如何纠正?这是我的代码:
from flask import Flask
from flask.ext.pymongo import PyMongo
app = Flask(__name__)
mongo = PyMongo(app)
from pymongo import Connection
connection = Connection()
db = connection.test_database
collection = db.test_collection
@app.route('/')
def home_page():
post = {"author":"mike","text":"jiii"}
posts = db.posts
posts.insert(post)
return posts.find()
if __name__=='__main__':
app.run(debug=True)