我使用GridFS存储图像文件。但我不知道如何使用PyMongo检索这些文件并在网页上显示它们。
@post('/blog')
def blog_post():
blog_title = request.forms.get('title')
blog_content = request.forms.get("content")
file_post = request.files.get('image_file')
if file_post and file_post.file:
raw = file_post.file.read()
filename = file_post.filename
DBNAME = "te3371db"
db = connection[DBNAME]
fs = gridfs.GridFS(db)
fs.put(raw,filename=filename)