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
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>
i really need help, any answer is accepted. i really hope anyone can help me. i precedently resolve identetion problem but now i dont see any problem…
TypeError: ‘SecureCookieSession’ object is not callable
127.0.0.1 – – [24/May/2020 18:06:19] “←[35m←[1mGET / HTTP/1.1←[0m” 500 –