Hi guys I am trying to pass information from and HTML page into a MySQL database via flask but im stuck and confused
This is my python - scores.py (Database connection is conn_db with credentials etc)
import mysql.connector as conn
from flask import (
render_template,
Flask,
jsonify,
request,
abort as ab
)
app = Flask(__name__, template_folder='C:\\Users\\thomp\\PycharmProjects\\com661_1819_team_30\\source\\template\\')
# Credentials here in code
WHO = '*********'
PWD = '********'
DATABASE = '********'
def conn_db():
return conn.connect(user=WHO,
password=PWD,
host='**********',
database=DATABASE
)
@app.route('/')
def index():
return render_template('scores.html')
@app.route('/addScore', methods=['POST'])
def add_score():
cnx = conn_db()
cursor = cnx.cursor()
MatchID = request.form['matchID']
Home_Score = request.form['homeScore']
Away_Score = request.form['awayScore']
print("Updating score")
if not request.json:
ab(400)
insert_score = "INSERT INTO scores (Match_ID, Home_Score, Away_Score) VALUES (%s,%s,%s)"
cursor.execute(insert_score, (MatchID, Home_Score, Away_Score))
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
And the following is my html file scores.html ( Posted as picture )
Any help is greatly appreciated, thanks guys

