AttributeError: 'function' object has no attribute 'read'
from fileinput import filename from re import L from fastapi import FastAPI, File, UploadFile import uvicorn import aiofiles from PIL import Image from fastapi.responses import FileResponse from typing import List app = FastAPI() @app.post("/upload-files") async def create_upload_files(files: List[UploadFile] = File(...)): for file in files: destination_file_path = "C:/Users/SMRUTI/Desktop/grey/"+file.filename #storing location async with aiofiles.open(destination_file_path, 'wb') as out_file: while content := await file.read(1024): #async read file await out_file.write(content) #async write file return FileResponse(destination_file_path) @app.post("/grey_image/") async def create_grey_img(files:List[UploadFile]= File(...)): for file in files: destination_file_path = "C:/Users/SMRUTI/Desktop/grey/"+file.filename #output file path async with aiofiles.open(destination_file_path, 'wb') as out_file: file= Image.open(filename) file.convert(L) while content := await file.read(1024): await out_file.write(content) return FileResponse(destination_file_path) if __name__ == '__main__': uvicorn.run(app, host='127.0.0.1', port=8000) print("running")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)