def update_studenta(id_studenta): data = flask.request.get_json() data["id"] = id_studenta print(data) db = mysql.get_db() cursor = mysql.get_db().cursor() cursor.execute( "UPDATE student SET indeks= %(indeks)s, ime= %(ime)s, prezime=%(prezime)s WHERE id=%(id)s", data) db.commit() return flask.jsonify({'status': 'ok'}), 200
def izmeni_jedan_predmet(id_predmeta): data = flask.request.get_json() data["id"] = id_predmeta print(data) db = mysql.get_db() cursor = mysql.get_db().cursor() cursor.execute( "UPDATE predmet SET naziv= %(naziv)s, skracenica= %(skracenica)s WHERE id=%(id)s", data) db.commit() return flask.jsonify({'status': 'ok'}), 200
def update_zadatak(id_zadatka): data = flask.request.get_json() data["id"] = id_zadatka print(data) db = mysql.get_db() cursor = mysql.get_db().cursor() cursor.execute( "UPDATE zadatak SET predmet_id= %(predmet_id)s, naslov= %(naslov)s, sadrzaj=%(sadrzaj)s, datum_provere=%(datum_provere)s WHERE id=%(id)s", data) db.commit() return flask.jsonify({'status': 'ok'}), 200
def dodaj_studenta(): data = flask.request.json db = mysql.get_db() cursor = db.cursor() print(flask.request.json) cursor.execute( "INSERT INTO student(indeks, ime, prezime) VALUES(%(indeks)s, %(ime)s, %(prezime)s)", data) db.commit() return flask.jsonify({"status": "Resource created."}), 204
def dodaj_zadatak(): data = flask.request.json db = mysql.get_db() cursor = db.cursor() print(flask.request.json) cursor.execute( "INSERT INTO zadatak(predmet_id, naslov, sadrzaj, datum_provere) VALUES(%(predmet_id)s, %(naslov)s, %(sadrzaj)s, %(datum_provere)s)", data) db.commit() return flask.jsonify({"status": "Resource created."}), 204
def dodaj_predmet(): data = flask.request.json db = mysql.get_db() cursor = db.cursor() print(flask.request.json) cursor.execute( "INSERT INTO predmet(naziv, skracenica) VALUES(%(naziv)s, %(skracenica)s)", data) db.commit() return flask.jsonify({"status": "Resource created."}), 204
def dobavi_studente(): cursor = mysql.get_db().cursor() cursor.execute('SELECT * FROM student') svi_studenti = cursor.fetchall() return flask.jsonify(svi_studenti), 200
def obrisi_studenta(id_studenta): db = mysql.get_db() cursor = mysql.get_db().cursor() cursor.execute('DELETE FROM student WHERE id= %s', (id_studenta)) db.commit() return flask.jsonify({'status': 'ok'}), 204
def dobavi_jednog_studenta(id_studenta): cursor = mysql.get_db().cursor() cursor.execute('SELECT * FROM student WHERE id= %s', (id_studenta)) jedan_student = cursor.fetchone() return flask.jsonify(jedan_student), 200
def dobavi_zadatke(): cursor = mysql.get_db().cursor() cursor.execute('SELECT * FROM zadatak') svi_zadaci = cursor.fetchall() return flask.jsonify(svi_zadaci), 200
def obrisi_zadatak(id_zadatka): db = mysql.get_db() cursor = mysql.get_db().cursor() cursor.execute('DELETE FROM zadatak WHERE id= %s', (id_zadatka)) db.commit() return flask.jsonify({'status': 'ok'}), 204
def dobavi_jedan_zadatak(id_zadatka): cursor = mysql.get_db().cursor() cursor.execute('SELECT * FROM zadatak WHERE id= %s', (id_zadatka)) jedan_zadatak = cursor.fetchone() return flask.jsonify(jedan_zadatak), 200
def obrisi_jedan_predmet(id_predmeta): db = mysql.get_db() cursor = mysql.get_db().cursor() cursor.execute('DELETE FROM predmet WHERE id= %s', (id_predmeta)) db.commit() return flask.jsonify({'status': 'ok'}), 204
def dobavi_jedan_predmet(id_predmeta): cursor = mysql.get_db().cursor() cursor.execute('SELECT * FROM predmet WHERE id= %s', (id_predmeta)) jedan_predmet = cursor.fetchone() return flask.jsonify(jedan_predmet), 200