How does < img src point to and merge a mongodb picture field?

  mongodb, question

Flask+mongoengine is a small station. The FileField field type is used in the model to store uploaded pictures to documents. Other text fields of the document record have already been displayed in the html template page in the form of {{ xx. field}}. How should the pictures be displayed?

Img src={{ xx. picture field}} … > certainly not. the source code shows: < GridFSProxy:%20018560.jpg >
The basic idea in. net is to build a general handler page, output the stream as a picture, and then use it as src attribute, which has not been written in flask or Python. Who can give some advice?

In another way, the idea is: src=”/img/{{xx. picture field. grid_id}}/ ”
Defined as a public View
Through the passed string objectid, the actual stored pictures are obtained through GridFS and output

from flask import Response
 from bson.objectid import ObjectId
 from mongoengine import *
 app.route('/img/<oid>/')
 def get_img(oid=None):
 if oid:
 proxy = GridFSProxy(grid_id=ObjectId(oid))
 return Response(proxy.read(),mimetype='image/jpeg')