如何获得关于Flask的查询字符串?

  • 问题:
  • 从flask文档中看不到如何获取查询字符串。我是新来的,看了医生,找不到!在

    所以

    @app.route('/')
    @app.route('/data')
    def data():
    query_string=??????
    return render_template("data.html")

  • 答案:
  • from flask import request

    @app.route('/data')
    def data():
    # here we want to get the value of user (i.e. ?user=some-value)
    user = request.args.get('user')