How to Serve Binary Protocol Buffer Data from Python

from package.proto import thing_pb2

something = thing_pb2.SomeThing(id=some_id)
something.simple_prop = 'foo'
something.message_prop.CopyFrom(msg_instance)

Django

return HttpResponse(
  protoInstance.SerializeToString(),
  content_type='application/octet-stream',
)

Flask

return Response(
  protoInstance.SerializeToString(),
  mimetype='application/octet-stream',
)