class Base64(BaseModel):
base64_str: str
photo_name: str
@app.post("/base64")
async def post_base64Image(b64: Base64):
imgstr = b64.base64_str
imgdata = base64.b64decode(imgstr)
filename = '%s.png' % b64.photo_name
with open(filename, 'wb') as f:
f.write(imgdata)
photo_id = 0
paths = int(photo_id / 1000) * 1000
with open(r"E:\images1024x1024\%05d\%05d.png" % (paths, photo_id), "rb") as img_file:
b64_output = base64.b64encode(img_file.read())
return {"Image" : b64_output.decode('utf-8')}
@app.post("/response_model/", response_model=Base64)
async def response_models(b64: Base64):
photo_id = 0
paths = int(photo_id / 1000) * 1000
with open(r"E:\images1024x1024\%05d\%05d.png" % (paths, photo_id), "rb") as img_file:
b64_output = base64.b64encode(img_file.read())
b64.base64_str = b64_output.decode('utf-8')
return b64
How could I send 1024*1024 base64 to it?
Or is my POST funtion is not well defined?
macOS
What error are you getting in your server console?
Not show any error, but just show nothing.
If you can provide us an example that doesn't depend on your local path, some image samples and explain how we can reproduce the same behavior, it will be very cool. :sunglasses: :+1:
Most helpful comment
If you can provide us an example that doesn't depend on your local path, some image samples and explain how we can reproduce the same behavior, it will be very cool. :sunglasses: :+1: