from flask import Flask, request, render_template import mysql.connector mydb = mysql.connector.connect( database="time_wasted", user="root" ) mydb.autocommit = True cursor = mydb.cursor() app = Flask(__name__) @app.get('/meetings/') def show(id): cursor.execute('SELECT * FROM meetings WHERE id=%s', [id]) result = cursor.fetchone() print(result) return { "id":result[0], "num_participants":result[1], "start_time":result[2].strftime("%Y-%m-%d %H:%M:%S"), "end_time":result[3] if result[3] == None else result[2].strftime("%Y-%m-%d %H:%M:%S") } @app.post('/meetings') def create(): cursor.execute('INSERT INTO meetings (num_participants) VALUES (%s)', [request.json['num_participants']]) return request.json @app.get('/') def home(id): return render_template('home.html', id=id)