We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f28c264 commit bcf32c2Copy full SHA for bcf32c2
app/routes/v2/locations.py
@@ -4,12 +4,19 @@
4
@app.route('/v2/locations')
5
def locations():
6
# Query parameters.
7
- country_code = request.args.get('country_code')
+ country_code = request.args.get('country_code', type=str)
8
+
9
+ # Retrieve all the locations.
10
+ locations = jhu.get_all()
11
12
+ # Filtering my country code if provided.
13
+ if not country_code is None:
14
+ locations = list(filter(lambda location: location.country_code == country_code.upper(), locations))
15
16
# Serialize each location and return.
17
return jsonify({
18
'locations': [
- location.serialize() for location in jhu.get_all(country_code=country_code)
19
+ location.serialize() for location in locations
20
]
21
})
22
0 commit comments