更多自定义响应类型

 

RedirectResponse

作用

  • 返回一个 HTTP 重定向响应
  • 默认情况下使用 307 状态码(临时重定向)

 

实际代码

from fastapi import FastAPI
from fastapi.responses import RedirectResponse


app = FastAPI()


@app.get("/typer")
async def redirect_typer():
    return RedirectResponse("https://typer.tiangolo.com")

 

源码

FastAPI(50)- 自定义响应之 RedirectResponse

 

相关文章:

  • 2022-01-21
  • 2020-10-13
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-04-08
  • 2022-12-23
  • 2021-11-13
猜你喜欢
  • 2021-12-09
  • 2021-10-07
  • 2021-10-21
  • 2021-09-24
  • 2021-11-19
  • 2021-07-23
  • 2022-02-01
相关资源
相似解决方案