You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
643 B
Python

import requests
import json
r = requests.get("http://127.0.0.1:5000/api/getcontent")
data = r.json()
def getcategory(category):
counter = 0
output=[]
for post in data:
if data[post]["category"] == category:
output.append(data[post]["title"])
counter+=1
if counter == 0:
print("Nothing found")
return output
def get(category, number):
counter = 1
output = []
for post in data:
if data[post]["category"] == category:
if counter == number:
output.append(data[post]["title"])
output.append(data[post]["content"])
counter+=1
return output
#getcategory("thesis")
#get("thesis", 2) #thesis, exercise or term