fastapi

Deepin15.11 安装python3.8

感情迁移 提交于 2020-04-06 05:22:33
因Deepin自带的python是3.5版本,很多时候不支持最新的框架如FASTAPI,因此需要升级。 第一步:升级系统 & 安装依赖 打算编译安装以前,首先升级系统,安装必要的依赖。这样可以避免之后安装 Python 时缺少第三方库的问题。 sudo apt install -y make build-essential libssl-dev zlib1g-dev sudo apt install -y libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm sudo apt install -y libncurses5-dev libncursesw5-dev xz-utils tk-dev 第二步:下载 Python 包并编译安装 python3.8我已经放在网盘了,地址: https://cloud.189.cn/t/JbUVJj6BJBny(访问码:d1ye) 从压缩包解压源代码: tar xvf Python-3.8.X.tgz 进入目录,执行./configure 配置构建文件,需要挺长时间: cd Python-3.8.X ./configure --enable-optimizations 第三步:编译并安装: make -j8 && sudo make altinstall 安装过程要输入sudo密码。

MongoDb with FastAPI

孤街浪徒 提交于 2020-02-06 08:07:20
问题 I am playing around with FastAPI a bit and wanted to connect it to a MongoDB database. I however am confused which ODM to choose between motor which is async and mongoengine. Also, in the NoSQL example here they have created a new bucket and also the called the code to connect to db every time it is used. However, both motor and mongoengine seem to prefer a global connection. So what would be a good way to connect to mongodb? 回答1: I believe you already got your answers in the issue forums of

How do I return an image in fastAPI?

ぃ、小莉子 提交于 2020-01-21 09:54:10
问题 Using the python module fastAPI, I can't figure out how to return an image. In flask I would do something like this: @app.route("/vector_image", methods=["POST"]) def image_endpoint(): # img = ... # Create the image here return Response(img, mimetype="image/png") what's the corresponding call in this module? 回答1: I had a similar issue but with a cv2 image. This may be useful for others. Uses the StreamingResponse . import io from starlette.responses import StreamingResponse app = FastAPI()