@app.post("/ai_read_meter")
async def refresh_capacity_energy_db(request: Request, file: bytes = File(...)):
    BASE_DIR = Path(__file__).resolve().parent

    """单文件上传(不能大于5M)"""
    if len(file) > 5 * 1024 * 1024:
        raise HTTPException(status_code=400, detail="每个文件都不能大于5M")
    name = hashlib.md5(file).hexdigest() + ".png"  # 使用md5作为文件名,以免同一个文件多次写入
    subpath = "media/uploads"
    # 如果不存在文件夹,则创建
    if not (folder := BASE_DIR / subpath).exists():
        await AsyncPath(folder).mkdir(parents=True)
    # 如果不存在文件,则写入
    if not (fpath := folder / name).exists():
        await AsyncPath(fpath).write_bytes(file)

    # image = np.asarray(bytearray(file), dtype="uint8")
    # start(i=2, image=cv2.imdecode(image, cv2.IMREAD_COLOR))

    return f"{subpath}/{name}"