小编cod*_*ddy的帖子

不带参数的 Depends 有什么作用?

我正在尝试使用 fastapi 来实现 JWT。目前正在查看以下库 fastapi-users FastAPI JWT Auth

在这两种情况下,我都在方法参数中看到 Depends() 。当参数中没有任何内容时,Depends 会做什么?

https://github.com/frankie567/fastapi-users/blob/master/fastapi_users/router/auth.py

@router.post("/login")
    async def login(
        response: Response, credentials: OAuth2PasswordRequestForm = Depends()
    ):
Run Code Online (Sandbox Code Playgroud)

https://indominusbyte.github.io/fastapi-jwt-auth/usage/basic/

@app.post('/login')
def login(user: User, Authorize: AuthJWT = Depends()):
Run Code Online (Sandbox Code Playgroud)

我不明白参数内有一个函数,但是你能教我当 Depends 没有参数时它会做什么吗?

python-3.x fastapi

12
推荐指数
2
解决办法
2392
查看次数

如何使用django-mobile检测iPad

我只是尝试了django-moble.

我非常喜欢这个概念,并帮助我的项目检测移动设备.但是,我试图找到iPad浏览器发出的请求.我已将以下内容添加到Settings.py FLAVORS =('full','mobile','ipad')

但它没有用.有人可以告诉我如何从这里开始吗?我还需要做什么?

以下是我的观点.

if get_flavour()=='full':
  t = loader.get_template('index.html')
elif get_flavour()=='ipad':
  t = loader.get_template('ipad.html')
else:
  t = loader.get_template('mobile.html')
Run Code Online (Sandbox Code Playgroud)

感谢您提前的时间.

django

2
推荐指数
1
解决办法
1388
查看次数

标签 统计

django ×1

fastapi ×1

python-3.x ×1