I am trying to do a GET request which should print a specific row from my database depending on what arguments are set. The argument should be a name of a course and I want it to get all data from the selected course. It might be a bit easier to explain this as a SQL query. The query could look like this "SELECT * FROM courselist WHERE course='D0024E';" where "course".
I have managed to do a fetchall() and receive all rows from a specific table, but I have not managed to get the parameters working correctly so I can get information from a specific course.
from flask import Flask
from flask import render_template
import requests
from flask import request
from flask import jsonify
import mysql.connector
app = Flask(__name__)
mydb = mysql.connector.connect(user='Mille',
                          auth_plugin='mysql_native_password',
                          password='jagheter12',
                          host='localhost',
                          database='paraplyet')
@app.route('/')
def index():
    return render_template("index2.html")
@app.route('/courses', methods= ["GET"])
def getStudentInCourse():
    myCursor2 = mydb.cursor()
    query2 = ("SELECT * FROM paraplyet.kursinfo")
    myCursor2.execute(query2)
    myresult2 = myCursor2.fetchall()
    return jsonify(myresult2)
if __name__ == '__main__':
    app.run()
 
     
    