Skip to content

Commit 02bcc88

Browse files
committed
use python's conditional syntax
1 parent 17f7a13 commit 02bcc88

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

home.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ class HomeHandler(RequestHandler):
99
def get(self, **kwargs):
1010
json = request.is_xhr or request.args.get('json', '')
1111

12-
if json:
13-
response = Response(mimetype = 'application/json')
14-
else:
15-
response = Response(mimetype = 'text/html')
12+
response = Response(mimetype = 'application/json' if json else 'text/html')
1613

1714
collection = FilterCollection(filters, request, response)
1815

random_quote.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ class RandomQuoteHandler(RequestHandler):
1212
def get(self, **kwargs):
1313
json = request.is_xhr or request.args.get('json', '')
1414

15-
if json:
16-
response = Response(mimetype = 'application/json')
17-
else:
18-
response = Response(mimetype = 'text/html')
15+
response = Response(mimetype = 'application/json' if json else 'text/html')
1916

2017
collection = FilterCollection(filters, request, response)
2118

0 commit comments

Comments
 (0)