摘要: 1.Response对象 1.Response Response类接收以下参数 content:str or bytes status_code:HTTP 状态码 headers:字符串字典 media_type:例如"text/html" Response会自动包含以下头信息 Content-Le 阅读全文
posted @ 2022-06-23 18:27 fatpuffer 阅读(443) 评论(0) 推荐(0) 编辑
摘要: 1.获取cookie信息 from fastapi import Cookie @users.get("/cookie") def cookie(cookie_id: Optional[str] = Cookie(None)): # 此处如果不使用Cookie转换参数,则会被当作查询参数处理 ret 阅读全文
posted @ 2022-06-23 14:41 fatpuffer 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 1.表单格式 from fastapi import Form app = FastAPI() @app.post('/login') def user_login(username: str = Form(...), password: str = Form(...)): """pip insta 阅读全文
posted @ 2022-06-23 14:07 fatpuffer 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 1.路径参数 1.方法中的形参需要和路径参数名保持一致 @app.get("/enum/{city}") def view_city(city: CityName): 2.对于路径作为路径参数,需要使用path转义 # file_path: "/etc/conf/nginx.conf" @app.g 阅读全文
posted @ 2022-06-23 13:46 fatpuffer 阅读(106) 评论(0) 推荐(0) 编辑