Python使用Flask框架获取当前查询参数的方法

yipeiwu_com5年前Python基础

本文实例讲述了Python使用Flask框架获取当前查询参数的方法。分享给大家供大家参考。具体如下:

这段代码实现Python的Flask框架下获取当前查询参数,即QueryString中的所有参数

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"),
  )

希望本文所述对大家的Python程序设计有所帮助。

相关文章

pandas 将list切分后存入DataFrame中的实例

如下所示: #-*- coding:utf-8 -*- import random import pandas as pd import numpy as np list=[1,2,...

Python通过递归遍历出集合中所有元素的方法

本文实例讲述了Python通过递归遍历出集合中所有元素的方法。分享给大家供大家参考。具体实现方法如下: 复制代码 代码如下:'''''通过递归遍历出集合中的所有元素 Created o...

Python读取sqlite数据库文件的方法分析

本文实例讲述了Python读取sqlite数据库文件的方法。分享给大家供大家参考,具体如下: import sqlite3 这是Python内置的,不需要pip install...

Python通过cv2读取多个USB摄像头

Python通过cv2读取多个USB摄像头

本文实例为大家分享了Python通过cv2读取多个USB摄像头的具体代码,供大家参考,具体内容如下 通过 cv2 可以轻易的拿到摄像头数据。 比如以下几步就能打开摄像头显示,并通过 q...

用Python进行行为驱动开发的入门教程

用Python进行行为驱动开发的入门教程

为驱动开发(Behavior-Driven Development,BDD)是一种卓越的开发模式。能帮助开发者养成日清日结的好习惯,从而避免甚至杜绝“最后一分钟”的情况出现,因此对提高代...