[英]How to get Params from the URL to the Authentification function? (Python, Flask)
I would like to get the Parameter " organisation " from the URL into my flask-httpauth password verification function.我想从 URL 中获取参数“组织”到我的 flask-httpauth 密码验证 function 中。 By now I just can get the value into my normal function:
到目前为止,我可以将值放入我的正常 function 中:
@app.route('/api/<organisation>/admin/todo', methods=['GET'])
@auth_admin.login_required
def get_admin_todo(organisation):
return jsonify({'organisation': organisation})
But I can't get it into the Authentification function:但我无法将其纳入认证 function:
@auth_admin.get_password
def get_password_admin(username):
organisation = "" #here I would like to have my organisation value
password = "my pwd"
return password
But I need this parameter for the identification.但是我需要这个参数来识别。 I want to identify a person by his organisation, username and his password.
我想通过他的组织、用户名和密码来识别一个人。 I would be very happy if anyone had any ideas.
如果有人有任何想法,我会很高兴。
Thank you very much非常感谢
snake蛇
You can use request.view_args['organisation']
:您可以使用
request.view_args['organisation']
:
organisation = request.view_args['organisation']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.