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
|
@ -45,3 +45,9 @@ def get_random_couplet_that_rhymes_with(params):
|
||||||
except:
|
except:
|
||||||
raise BadRequest(f'Error 400: Sorry, there are not at least two lines that rhyme with {params['topic']}.')
|
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