首页 > 其他分享 >[FastAPI-21]响应状态码

[FastAPI-21]响应状态码

时间:2023-03-24 11:47:56浏览次数:37  
标签:status username 21 FastAPI app 响应 user password

from fastapi import FastAPI,status
from pydantic import BaseModel

app = FastAPI()

'''
响应状态代码 status
'''

class User(BaseModel):
    username : str
    password : str

@app.post("/login",status_code=status.HTTP_200_OK)
def login(user : User):
    return {
        "username":user.username,
        "password":user.password
    }

标签:status,username,21,FastAPI,app,响应,user,password
From: https://www.cnblogs.com/leoshi/p/17250978.html

相关文章

  • 聊聊Python中的GIL https://www.cnblogs.com/ArsenalfanInECNU/p/9968621.html
    抄自:https://www.cnblogs.com/ArsenalfanInECNU/p/9968621.htmlGIL的全称是GlobalInterpreterLock,全局解释器锁。因为Python的执行依赖于解释器。Python最初的设计理......
  • [FastAPI-18]Filed请求体校验
    importrandomfromfastapiimportFastAPIfrompydanticimportField,BaseModelimporttypingapp=FastAPI()'''请求体的每一个字段需要单独校验name长度最......
  • ubuntu21设置语言
    概述ubuntu设置language编码执行envubuntu-21.1001、查看localeroot@mvpbang:~#localeLANG=C.UTF-8LANGUAGE=LC_CTYPE="C.UTF-8"LC_NUMERIC="C.UTF-8"LC_TIM......
  • [FastAPI-14]pydantic多个请求体
    fromfastapiimportFastAPIfrompydanticimportBaseModelapp=FastAPI()'''多个请求体{"user":{"username":"string","password":"string"......
  • [FastAPI-13]pydantic请求体接收数据
    fromfastapiimportFastAPIfrompydanticimportBaseModelapp=FastAPI()'''创建继承BaseModel的类,定义模型user路径函数中定义形参user,类型为User通过对象use......
  • [FastAPI-11]Query参数校验
    importtypingfromfastapiimportFastAPI,Queryapp=FastAPI()'''查询参数使用Query校验类似路由转换使用Path校验物品名称最小3位,最大10位default=None参数......
  • CentOS 7 : wpa_supplicant (CESA-2021:0808) Vulnerability_day 16
    今天要跟大家分享的是关于CentOS的系统缺陷。下面是关于这个问题的具体的描述:TheremoteCentOSLinux7hosthasapackageinstalledthatisaffectedbyavulnerabil......
  • 最新flstudio_win64_21.0.2.3399安装激活教程
    大家好,今天给大家最新FLStudio21中文版,它是一款非常专业宿主DAW编曲软件,对于音乐编辑处理的领域内的人而言,是非常能够满足需求的一款工具。FLStudio21拥有强大且专业的创作......
  • P4221 [WC2018]州区划分 题解
    题目链接题目描述给出\(n\)个城市,\(m\)条边,一个划分合法当且仅当所有划分中的点集和集合中点之间存在的边集所构成的图不构成欧拉回路且联通。定义一个点集的值为......
  • FastAPI: 极速开发Python Web应用的未来之星
    我在工作中经常使用Flask来开发Web应用。但是随着项目规模的增长,我发现自己需要写越来越多的重复代码,同时Flask并没有提供一个良好的数据验证和文档生成工具。有一天,我听说......