首页 > 解决方案 > Flask:如何使用第二个查询获取参数,该参数用于第一个查询调用的函数?

问题描述

它会是这样的:

@app.route('/phone_code', methods=['POST'])
def get_phone_code():
    return request.args.get('phone_code')

@app.route('/sign_in', methods=['GET', 'POST'])
def sign_in():
    with pyrogram.Client(
        phone_number=request.args.get('phone_number')
        phone_code=get_phone_code()) as client:
        pass
    return 'some specific server stuff'

那么如何从get_phone_code另一个 Flask 请求中获取代码呢?

UPD:首先我需要调用sign_in()which runssend_code()函数并生成phone_code_hash用于检查有效性的phone_code所以sign_in()必须在获取之前调用phone_code

标签: pythonflask

解决方案


推荐阅读