I am calling a django rest framework get api to create a barcode. Its working fine when I tried to save it as an image.
@api_view(['GET'])
def mybarcode(request):
from elaphe import barcode
code = barcode('datamatrix', "sampletext",
encoding='utf-8', scale=2,
options=dict(columns=24, rows=24),
margin=2, data_mode='50bits')
code.save("mybarcode.jpg")
return Response({'status': True})
This working fine when I call this API as "http://127.0.0.1:9999/api/v1/testbarcode". An image will be created with the name "mybarcode.jpg" and the api return its status as True.
But I would like to return the image as the result of this api call. Because I have to include this in a image tag.
<img src='http://127.0.0.1:9999/api/v1/testbarcode' />
Is there any way to do this?