在 Flask 中,我使用以下片段来启用HTTP身份验证:
谢谢。
def authenticate():
return Response('<Why access is denied string goes here...>', 401, {'WWW-Authenticate':'Basic realm="Login Required"'})
根据我之前使用 Flask 的经验,如果某人的凭据不正确,我想让他们知道,只需调用以下代码:
abort(401)
这将为您提供基本的 Apache 401 响应。有谁知道我如何使用上面的片段实现它吗?谢谢。
abort(401, '<为什么访问被拒绝的字符串在此处...>')
也可以使用。 - Michael Scheper