Python Flask框架下获取当前查询参数的源码

293 阅读1分钟

把写代码过程中比较好的代码段珍藏起来,如下代码段是关于Python Flask框架下获取当前查询参数的的代码。

from flask import Flask, render_template, request

Initialize the Flask application

app = Flask(__name__)
@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"),
    )