Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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')
Add Comment
Please, Sign In to add comment