fastapi - FastAPI Async Def 调用常用函数
问题描述
我想将上传部分包装在一个通用函数中,因为它在多个 API 路由中使用,但是由于它在这里使用,我该怎么做async def
。
@app.post("/api/od")
async def image_classification(files: typing.List[fastapi.UploadFile] = fastapi.File(...)):
upload_path = pathlib.Path("upload")#.joinpath(token)
upload_path.mkdir(exist_ok=True)
...
return results
解决方案
推荐阅读
- c# - 将自定义属性添加到 OData 子集合
- ruby-on-rails - 在 Heroku 上每 2 分钟运行一次 rake 任务的最佳方式
- r - 无法在 R 闪亮的应用程序中显示模式警报
- vb.net - 如何在 vbnet 上随机化测验
- macos - 如何使用 Delphi 在 MacOS 上检测正在运行的调试器
- assembly - 当它们有符号与无符号时,在 40h + 40h 中设置了哪些标志?
- node.js - 如何验证 JWT 是否仍然有效?
- python - 我无法创建 post_detail 和 post_list
- c# - XAML 中 Frame 的 System.InvalidCastException
- java - 死代码消除是否捕获了具有副作用的空循环?