-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
47 lines (37 loc) · 1.2 KB
/
api.py
File metadata and controls
47 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from database.main import KataDasarDb, KataDasar
class ApiKataDasar():
def __init__(self):
self.db = KataDasarDb()
def check_words(self, word):
words = self.db.get_item_by_column(value= word, column=KataDasar.kata)
if (words == None):
return {
'status': False,
'message': "Kalimat belum ada pada Database"
}
else:
return {
'status': True,
'message': "Kalimat terdapat pada Database"
}
def get_words_with_length(self, length, max, random=False):
if (random):
words = self.db.get_random_words_by_length(length, max)
else:
words = self.db.get_words_by_length(length, max)
if (words == None):
return {
'status': False,
'data': []
}
else:
listWords = []
for w in words:
listWords.append({
"kata": w.kata,
"jenis_kata": w.tipe,
})
return {
'status': True,
'data': listWords
}