generated from mwc/lab_server
im done
This commit is contained in:
@@ -37,5 +37,32 @@ def guess_answer(params):
|
||||
}
|
||||
except Riddle.DoesNotExist:
|
||||
raise NotFound("Riddle not found")
|
||||
|
||||
|
||||
@route_get('lines/random', args={})
|
||||
def random_line(params):
|
||||
line = Line.objects.random()
|
||||
if not line:
|
||||
raise NotFound("No lines found")
|
||||
return {"line": str(line)}
|
||||
|
||||
@route_get('lines/short', args={})
|
||||
def short_line(params):
|
||||
line = Line.objects.filter(clean_text__length__lt=40).random()
|
||||
|
||||
if not line:
|
||||
raise NotFound("No short line found")
|
||||
|
||||
return {"line": str(line)}
|
||||
|
||||
@route_get('lines/about', args={'topic': str})
|
||||
def line_about(params):
|
||||
topic = params['topic']
|
||||
line = Line.objects.filter(clean_text__icontains=topic).random()
|
||||
|
||||
if not line:
|
||||
raise NotFound("No line found containing that topic")
|
||||
|
||||
return {
|
||||
"line": str(line),
|
||||
"topic": topic
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user