Skip to content

Commit

Permalink
check valid words by prompt endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
carreb committed Feb 24, 2022
1 parent adc60e1 commit 483f66e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,17 @@ def check_for_letters_in_word_hyphenated(inputword, promptedletters):
return json.dumps({'response': 'false', 'reason': 'word not in list', 'word': inputword.lower()})
else:
return json.dumps({'response': 'false', 'reason': 'no prompt letters in word'})

@app.route('/checkvalidwordshyphenated/<prompt>', methods=['GET'])
def check_valid_words(prompt):
with open('./dict/hyphen-dict.txt') as f:
hyphenatedwords = f.readlines()
hyphenList = []
for word in hyphenatedwords:
if prompt in word:
hyphen = word.replace('\n', '')
h = hyphen.replace('\u00e2\u20ac\u2122', "'")
hyphenList.append(h.lower())
return json.dumps({'response': hyphenList})

if __name__ == 'main':
print('True')
Expand Down

0 comments on commit 483f66e

Please sign in to comment.