generated from mwc/lab_server
Finished! I implemented a route to get a word that
rhymes with whatever they input.
This commit is contained in:
parent
eb7117cbf7
commit
54b0fbd6d8
|
@ -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']}.')
|
Loading…
Reference in New Issue