示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
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
示例#5
0
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
示例#6
0
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
示例#7
0
def dobavi_studente():
    cursor = mysql.get_db().cursor()
    cursor.execute('SELECT * FROM student')
    svi_studenti = cursor.fetchall()
    return flask.jsonify(svi_studenti), 200
示例#8
0
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
示例#9
0
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
示例#10
0
def dobavi_zadatke():
    cursor = mysql.get_db().cursor()
    cursor.execute('SELECT * FROM zadatak')
    svi_zadaci = cursor.fetchall()
    return flask.jsonify(svi_zadaci), 200
示例#11
0
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
示例#12
0
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
示例#13
0
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
示例#14
0
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