小编Vya*_*lav的帖子

FastAPI 不会替换 GET 请求中的“+”加号

我知道这不是 FastAPI 问题,但如何使用 FastAPI 避免这种情况?

例如:

from fastapi import FastAPI

app = FastAPI()


@app.get('/')
async def root(q: str):
    return {"message": f"{q}"}
Run Code Online (Sandbox Code Playgroud)

发出以下请求:

http://127.0.0.1:8000/?q=1+1
Run Code Online (Sandbox Code Playgroud)

返回:

{"message":"1 1"}
Run Code Online (Sandbox Code Playgroud)

python http urlencode starlette fastapi

1
推荐指数
1
解决办法
1609
查看次数

标签 统计

fastapi ×1

http ×1

python ×1

starlette ×1

urlencode ×1