Skip to content

Commit 34b27c5

Browse files
author
Vasily Fotin
committed
Updated JSON scheme for /formatted/ route
1 parent 57666e2 commit 34b27c5

File tree

4 files changed

+77
-16
lines changed

4 files changed

+77
-16
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ verify_ssl = true
55

66
[dev-packages]
77
bandit = "*"
8+
pylint = "*"
89

910
[packages]
1011
flask = "*"

Pipfile.lock

Lines changed: 62 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/routes/formatted.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def full():
1212
recovered = get_data('recovered')
1313

1414
# prepare output dictionary
15-
output = []
15+
locationsOutput = []
1616

1717
# Formatting
1818
for locationConfirmed in confirmed["locations"]:
@@ -45,12 +45,19 @@ def full():
4545
}
4646

4747
# add current location to the output
48-
output.append(locationOutput)
49-
50-
outputJSON = jsonify(output)
48+
locationsOutput.append(locationOutput)
49+
50+
finalOutput = {
51+
'locations': locationOutput,
52+
'latest': {
53+
'confirmed': confirmed['latest'],
54+
'deaths': deaths['latest'],
55+
'recovered': recovered['latest'],
56+
}
57+
}
5158

5259
f = open( 'app/static/data.json', 'w' )
53-
f.write(str(output))
60+
f.write(str(finalOutput))
5461
f.close()
5562

56-
return jsonify(output)
63+
return jsonify(finalOutput)

app/static/data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)