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

yipeiwu_com6年前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程序设计有所帮助。

相关文章

python使用tomorrow实现多线程的例子

python使用tomorrow实现多线程的例子

如下所示: import time,requestes from tomorrow import threads @threads(10)#使用装饰器,这个函数异步执行 def d...

Python机器学习算法之k均值聚类(k-means)

Python机器学习算法之k均值聚类(k-means)

一开始的目的是学习十大挖掘算法(机器学习算法),并用编码实现一遍,但越往后学习,越往后实现编码,越发现自己的编码水平低下,学习能力低。这一个k-means算法用Python实现竟用了三天...

用python处理图片实现图像中的像素访问

用python处理图片实现图像中的像素访问

前面的一些例子中,我们都是利用Image.open()来打开一幅图像,然后直接对这个PIL对象进行操作。如果只是简单的操作还可以,但是如果操作稍微复杂一些,就比较吃力了。因此,通常我们加...

基于Django的ModelForm组件(详解)

创建类 from django.forms import ModelForm from django.forms import widgets as wd from app01 im...

python3利用ctypes传入一个字符串类型的列表方法

c语言里:c_p.c #include <stdio.h> void get_str_list(int n, char *b[2]) { printf("in c s...