【发布时间】:2020-10-31 17:12:00
【问题描述】:
我是网络通信的新手。 我使用 ubuntu 并尝试学习 fastapi。 假设我使用 curl 发布了一个文件。似乎普遍认为这是最好的方法:
curl -F "file=@image1.jpg" http://127.0.0.1:8000/image -v
现在,在服务器端,我想检索图像并将每个像素值加 1,然后返回它。但我现在知道如何从 curl 中“捕捉”图像,我该怎么做?现在,我只有下面的虚拟函数,它没有做任何智能:
@app.post("/image")
async def post_test():
print("I don't know how to catch the image :( ")
return {"You sent an image..."}
请帮助我应该如何编写 post_test 函数! (Flask 也可以。)
【问题讨论】:
-
您阅读过request files 文档吗?