Skip to content
Snippets Groups Projects
Commit 9b92e640 authored by dnsadmin's avatar dnsadmin
Browse files

Retab és 1. Feladat

parent c5961896
No related branches found
No related tags found
No related merge requests found
...@@ -139,6 +139,50 @@ def verb_test(): ...@@ -139,6 +139,50 @@ def verb_test():
# it also shows you how to access the method used and the decoded JSON data # it also shows you how to access the method used and the decoded JSON data
return jsonify(method=request.method, data=request.get_json(), url=request.url) return jsonify(method=request.method, data=request.get_json(), url=request.url)
@app.route('/jarmuvek.json', methods=["GET"])
def vehicles():
conn = get_db()
try:
cur = conn.cursor()
try:
cur.execute('select jarmu_kulcs, rendszam, uzembehelyezes from jarmu')
results = []
for id, rsz, uh in cur:
results.append({'jarmu_kulcs': id, 'rendszam': rsz, 'uzembehelyezes': uh.isoformat()})
return jsonify(jarmuvek=results)
finally:
cur.close()
finally:
conn.close()
@app.route('/jarmuvek/<jarmu_kulcs>.json')
def show_vehicle(jarmu_kulcs):
conn = get_db()
try:
try:
cur = conn.cursor()
cur.execute('select telephely, berelheto, rendszam, alvazszam, uzembehelyezes, muszaki_ervenyesseg, marka, tipus, szin, teljesitmeny, ulesek, legkondicionalo from jarmu where jarmu_kulcs= :jk', jk=jarmu_kulcs)
results = []
for telephely, berelheto, rendszam, alvazszam, uzembehelyezes, muszaki_ervenyesseg, marka, tipus, szin, teljesitmeny, ulesek, legkondicionalo in cur:
results.append({
"telephely": telephely,
"berelheto": bool(berelheto),
"rendszam": rendszam,
"alvazszam": alvazszam,
"uzembehelyezes": uzembehelyezes.isoformat(),
"muszaki_ervenyesseg": muszaki_ervenyesseg.isoformat(),
"marka": marka,
"tipus": tipus,
"szin": szin,
"teljesitmeny": teljesitmeny,
"ulesek": ulesek,
"legkondicionalo": bool(legkondicionalo)
})
return jsonify(jarmuvek=results)
finally:
cur.close()
finally:
conn.close()
def get_db(): def get_db():
"""Connects to the RDBMS and returns a connection object""" """Connects to the RDBMS and returns a connection object"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment