Added a route to get a random poem.

This commit is contained in:
Danielle Tear 2024-05-01 19:45:28 -04:00
parent afcd25178e
commit 438948be40
1 changed files with 5 additions and 1 deletions

View File

@ -57,4 +57,8 @@ def get_couplet_with_rhyme(params):
if line.rhyming_lines().count() > 0:
flag = False
rhyming_line = line.rhyming_lines().random()
return {'couplet' : [line, rhyming_line], 'rhyme' : params['rhyme']}
return {'couplet' : [line, rhyming_line], 'rhyme' : params['rhyme']}
@route_get('poems/random', args={})
def get_random_line(params):
return {'poem': Poem.objects.random()}