Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么烧瓶闪光灯不工作?_Python_Flask_Python Requests - Fatal编程技术网

Python 为什么烧瓶闪光灯不工作?

Python 为什么烧瓶闪光灯不工作?,python,flask,python-requests,Python,Flask,Python Requests,这是我的python视图代码。我有一个闪光。但它不会显示任何类型的flash前端 @auth.route('/admin/project/add',methods = ['POST', 'GET']) def addproject(): if request.method == 'POST': projectname = request.form['projectname'] c, conn = connection(

这是我的python视图代码。我有一个闪光。但它不会显示任何类型的flash前端

  @auth.route('/admin/project/add',methods = ['POST', 'GET']) 
    def addproject():
        if request.method == 'POST':
            projectname = request.form['projectname']
            c, conn = connection()
            query = "SELECT Count(id) from projects WHERE project='{}'".format(projectname)
            c.execute(query)
            values = c.fetchall
            conn.close() 
            if (values == 0):
                flash("success")
                return render_template('addproject.html') 
            else:
                flash("Project already exists. Please goto projects page and confirm. If it is and error, please contact devloper.")
                return render_template('addproject.html') 
        else:        
            return render_template('addproject.html')      
在模板中,我添加了以下内容:

{% with messages = get_flashed_messages() %}
         {% if messages %}
            <ul>
               {% for message in messages %}
               <li><{{ message }}</li>
               {% endfor %}
            </ul>
         {% endif %}
      {% endwith %}  

需要执行:projectname


打字错误警报!检查闪存是否存在循环我更正了它..但我没有得到闪存可能与条件有关,请尝试在if request.method=='POST':之前放置一个闪存以检查我已尝试..它没有显示任何内容HTML部分我也检查了..因为它应该是从request.form首先获取数据,请尝试
from flask import flash, redirect, render_template, url_for, request
cur = conn.cursor()
query = """SELECT Count(id) from projects WHERE project= :project"""
cur.execute(query, project = projectname)