Python使用Flask框架獲取當(dāng)前查詢參數(shù)的方法

字號(hào):


    這篇文章主要介紹了Python使用Flask框架獲取當(dāng)前查詢參數(shù)的方法,實(shí)例分析了query_string獲取查詢參數(shù)的技巧,需要的朋友可以參考下
    本文實(shí)例講述了Python使用Flask框架獲取當(dāng)前查詢參數(shù)的方法。分享給大家供大家參考。具體如下:
    這段代碼實(shí)現(xiàn)Python的Flask框架下獲取當(dāng)前查詢參數(shù),即QueryString中的所有參數(shù)
    from flask import Flask, render_template, request
    # Initialize the Flask application
    app = Flask(__name__)
    # This is a catch all route, to catch any request the user does
    @app.route('/')
    def index():
    qs = request.query_string
    return render_template('index.html', query_string=qs)
    if __name__ == '__main__':
    app.run(
    host="0.0.0.0",
    port=int("80"),
    )
    希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。