FastAPI Cookie 参数,Header参数
Last updated
Last updated
# coding: utf8
from typing import Optional
from fastapi import FastAPI, Header, Cookie
app = FastAPI()
@app.get('/header')
# User-Agent: PostmanRuntime/7.26.8
{
"User-Agent": "PostmanRuntime/7.26.8"
}
# cookie: cookie=tom
{
"cookie": "tom"
}
# 自定义 Header, Cookie
curl --location --request GET 'http://10.11.9.247:8000/users' \
--header 'cookie: name="admin"' \
--header 'X-Token: token
'
{
"cookie_name": "admin",
"header_X_Token": "token"
}