Finished! I implemented a route to get a word that

rhymes with whatever they input.
This commit is contained in:
Cory 2024-05-07 11:23:17 -04:00
parent eb7117cbf7
commit 54b0fbd6d8
1 changed files with 7 additions and 1 deletions

View File

@ -44,4 +44,10 @@ def get_random_couplet_that_rhymes_with(params):
return {'lines': [first_line.text,second_line.text]}
except:
raise BadRequest(f'Error 400: Sorry, there are not at least two lines that rhyme with {params['topic']}.')
@route_get('word/rhyme',args={'rhyme': str})
def get_random_word_that_rhymes_with(params):
try:
return {'word': Rhyme.get_rhyme_for_word(params['rhyme']).lines.exclude(clean_text__endswith=params['rhyme']).random().last_word()}
except:
raise BadRequest(f'Error 400: Sorry, there are no words that rhyme with {params['rhyme']}.')