烧瓶TypeError:'SecureCookieSession'对象不可调用

问题描述 投票:0回答:1
from flask import Flask, request, redirect,url_for,render_template,session
#from PIL import Image
from apiPOI1 import api
app=Flask(__name__)
db=api('sqlite3\\secondaprova.db')
app.config['SECRET_KEY']='insgamabile'
@app.route('/login',methods=['GET', 'POST'])
def login():
    if request.method=='POST':
        u = request.form['utente']
        p = request.form['password']
        if db.checkLogin(u,p)==1:
            session['user']=u
            return redirect(url_for('homedip'))
        if db.checkLogin(u,p)==2:
            session['user']=u
            return redirect(url_for('homecliente'))
    else:
        return render_template("paginaAccesso.html", messaggio='utente non trovato')
@app.route('/logout',methods=['GET'])
def logout():
    del session['user']
    return redirect(url_for('home'))
@app.route('/',methods=['GET', 'POST'])
def homedip():
    if 'user' in session():
        if request.method=='GET':
            return render_template('paginariservata.html', nome=session['user'],password="")
        if request.method=='POST':
            if request.form:
                cf = request.form['cf']
                cc = request.form['cc']
                month = request.form['month']
                year = request.form['year']
                cvv= request.form['cvv']
                ct=request.form['ct']
                password=db.addcliente( cf, cc, month, year, cvv, ct)
                return render_template('paginariservata.html', nome=session['user'],password=password)
    else:
        return render_template('PaginaAccesso.html')
@app.route('/cliente',methods=["GET"])
def homecliente():
    if 'user' in session():
        return render_template('paginariservatacliente.html', user=session['user'])
        #if request.form:
            #img = Image.open(request.form['immagine'])
            #codicepagina=db.checkqr(img)
            #return render_template(codicepagina)

    else:
        return redirect(url_for('login'))
if __name__ == '__main__':
    app.run('0.0.0.0')

flask error

paginariservata.html

<html>
    <head>
        <title>
            account di {{nome}}
        </title>
    </head>
    <body>
        <form action="apiPOI1.py" method="GET|POST">


            <table align="center">
                <tr>
                    <td><img src="immagini/logo.jpg" ></td>
                </tr>
                <tr>
                    <td><h1 align="center" style="color:blue;">creazione nuovo cliente</h1></td>
                </tr>

                <tr>
                    <td><input type="text" name="cf" value="codicefiscle"></td>
                </tr>
                <tr>
                    <td><input type="text" name="cc" value="cc"></td>
                </tr>
                <tr>
                    <td><input type="text" name="month" value="month"></td>
                    <td><input type="text" name="year" value="year"></td>
                </tr>
                <tr>
                    <td><input type="text" name="cvv" value="cvv"></td>
                </tr>
                <tr>
                    <td><input type="text" name="ct" value="ct"></td>
                </tr>
                <tr>
                    <td><input type="submit" onclick="apiPOI1.py"></td>
                </tr>
                <tr>
                    <td>{{password}}</td>
                </tr>
            </table>
            <a href="{% url_for('logout') %}">logout</a>

        </form>
    </body>
</html>

我真的需要帮助,任何答案都可以接受。我真的希望有人能帮助我。我先解决了识别问题,但现在看不到任何问题...TypeError:“ SecureCookieSession”对象不可调用127.0.0.1--[2020年5月24日18:06:19]“←[35m←[1mGET / HTTP / 1.1←[0m” 500-

python html flask
1个回答
0
投票

apiPOI.py

import sqlite3 
import random as r
class api:
    def __init__(self, db):
        self.con = sqlite3.connect(db)
        self.cursor=self.con.cursor()
        self.con.commit()
    def addcliente(self, cf, cc, m, y, cvv, ct):
        password=r.randint(1000,10000)
        self.cursor.execute('INSERT INTO cliente values(?,?,?,?,?,?,?)', (cf,password,cc,m,y,ccv,ct))
        self.con.commit()
        return password
    def checkLogin(self, user, pwd):
        self.cursor.execute('SELECT * FROM dipendente where nomeutente = ? and password = ?', (user, pwd))
        records= self.cursor.fetchone()
        if records:
            return 1
        else:
            self.cursor.execute('SELECT * FROM cliente where codicefiscale = ? and password = ?', (user, pwd))
            records= self.cursor.fetchone()
            if records:
                return 2
            else:
                return 0

    def checkqr(self,img):
        self.cursor.execute('SELECT paginahtml FROM qr where qrcode=?', (img))
        records= self.cursor.fetchone()
        if records:
            return records
        else:
            return False
© www.soinside.com 2019 - 2024. All rights reserved.