ming 3 rokov pred
rodič
commit
692622b09e
1 zmenil súbory, kde vykonal 16 pridanie a 0 odobranie
  1. 16 0
      main.py

+ 16 - 0
main.py

@@ -20,4 +20,20 @@ async def get_tags():
     
     return json_dump
 
+@app.get("/courses")
+async def get_courses(tag_string):
+    course_dict = {}
+    statement = 'SELECT course_id from course_tag where tag_id IN'+tag_string
+
+    course_id_string = '('
+    for row in db.query(statement):
+        course_id_string = course_id_string + str(row['course_id'])+","
+    course_id_string=course_id_string[:-1]
+    course_id_string = course_id_string+')'
+
+    statement = 'SELECT id,name from course_table where id IN'+course_id_string    
+    for row in db.query(statement):
+        course_dict[row['id']]=row['name']
+        json_dump = json.dumps(course_dict, ensure_ascii=False)
+    return json_dump