py读取本地图片并返回图片给前端base64格式

py读取本地图片并返回图片给前端base64格式

直接贴代码,有用请收藏

from fastapi import FastAPI
from get90V import resBody, getRewriteUrl
from get90V import resolveTxSelectVideo, exchangePlayUrl
from django.http.response import HttpResponse
@app.get('/img')
def getVlist(request):
    path = r"C:\Users\ll\Desktop\店铺组合图.png"
    fileOpen = open(path, 'rb')
    import base64
    imgBs4 = base64.b64encode(fileOpen.read()).decode()
    # return HttpResponse(fileOpen.read(), content_type='image/jpg')
    # pass
    return imgBs4

你可能感兴趣的:(pythone,日记,django,python,后端,fastapi)