检测前端传送空值的判断方法
使用自定义的状态码检测前端传空值的方法
from sanic.exceptions import SanicException, add_status_code # 自定义状态码 @add_status_code(7416) class Attribute(SanicException): pass # 定义一个类来判断前端传的值是否为空 class httpnew(HTTPMethodView): def getparms(self, request, *args, **kwargs): try: return request.json.get(*args, **kwargs).strip() except AttributeError as e: raise Attribute('sasadadad') # 从教师APP过来通过手机号码获取教师MID class GetTeacherMID(httpnew): # @jwtauth async def post(self, request): TeacherCode = self.getparms(request, "TeacherCode", "")