<commit_before>from flask import Flask, render_template,redirect,request,session
from mysqlconnection import MySQLConnector
import re
app = Flask(__name__)
app.secret_key = "fred"
mysql = MySQLConnector(app,'email_validation')

@app.route('/')
def home():
    if not 'email' in session:
        session['email'] = ""
    if not 'name' in session:
        session['name'] = ""
    return render_template('index.html',name=session['name'],email=session['email'])


@app.route('/results' )
def results():
    data = mysql.query_db("SELECT name,email,id FROM user")
    return render_template('results.html',data=data)


@app.route('/addUser',methods=['POST'])
def addUser():
    session["name"] = request.form["name"]
    session["email"] = request.form["email"]
    #if not re.match(session["email"],r"[a-Z0-9_]@.*\..*"):
    if len(session["name"]) < 1 or len(session["email"]) < 1:
        return redirect("/")
    query = "INSERT INTO email_validation.user (email, name) VALUES (:email,:name)";
    data = {
            'email':session['email'],
            'name':session['name']
            }
    mysql.query_db(query,data)
    return redirect('/results')


@app.route('/deleteUser',methods=['POST'])
def deleteUser():
    userid = request.form["userid"]
    query = "DELETE FROM email_validation.user WHERE id=:id";
    data={"id":userid}
    mysql.query_db(query,data)
    return redirect('/results')

app.run(debug=True)<commit_msg>validation work, ready to submit<commit_after>from flask import Flask, render_template,redirect,request,session
from mysqlconnection import MySQLConnector
import re
app = Flask(__name__)
app.secret_key = "fred"
mysql = MySQLConnector(app,'email_validation')

@app.route('/')
def home():
    if not 'email' in session:
        session['email'] = ""
    if not 'name' in session:
        session['name'] = ""
    return render_template('index.html',name=session['name'],email=session['email'])


@app.route('/results' )
def results():
    data = mysql.query_db("SELECT name,email,id FROM user")
    return render_template('results.html',data=data)


@app.route('/addUser',methods=['POST'])
def addUser():
    session["name"] = request.form["name"]
    session["email"] = request.form["email"]
    if not re.match(r"\b[a-z]+[a-z0-9_]*@.+\..+\b",session["email"],):
        #if len(session["name"]) < 1 or len(session["email"]) < 1:
        return redirect("/")
    query = "INSERT INTO email_validation.user (email, name) VALUES (:email,:name)";
    data = {
            'email':session['email'],
            'name':session['name']
            }
    mysql.query_db(query,data)
    return redirect('/results')


@app.route('/deleteUser',methods=['POST'])
def deleteUser():
    userid = request.form["userid"]
    query = "DELETE FROM email_validation.user WHERE id=:id";
    data={"id":userid}
    mysql.query_db(query,data)
    return redirect('/results')

app.run(debug=True)
{'fraction_non_alphanumeric': 0.18103744417725867, 'fraction_numerical': 0.0027481964960494676, 'mean_word_length': 4.090909090909091, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6609350', 'n_tokens_mistral': 924, 'n_tokens_neox': 903, 'n_words': 187}