def qr_code_img(request):
face_id = request.session.get("userfaceid")
print(face_id)
user_to = request.POST.get('to')
abs_url = request.build_absolute_uri()
url_root = abs_url.split('/con')[0]
qrcode_url = os.path.join(url_root, f'media/html/source/{user_to}.html')
print(qrcode_url)
img = qrcode.make(qrcode_url)
buf = BytesIO() # 创建一个BytesIO临时保存生成图片数据
img.save(buf) # 将图片字节数据放到BytesIO临时保存
image_stream = buf.getvalue() # 在BytesIO临时保存拿出数据
response = HttpResponse(image_stream, content_type="image/jpg") # 将二维码数据返回到页面
return response