Skip to content

Commit 4367c70

Browse files
committed
police api
1 parent 9c488fb commit 4367c70

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

application/api/external_api.py

+29-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from servers import worldbank
2424
from servers import geocoding
2525
from servers import foodstandartsagency
26+
from servers import police
2627

2728
# Flask-Cache (configured to use App Engine Memcache API)
2829
cache = Cache(app)
@@ -42,6 +43,7 @@
4243
'worldbank' : 1,
4344
'geocoding' : 2,
4445
'foodstandartsagency' : 3
46+
'police' : 4
4547
}
4648

4749
@external_api.route('/api/'+str(servers['worldbank'])+'/<dataType>/<date>/<format>')
@@ -65,13 +67,36 @@ def getFoodStandartsAgencyData(name, location, format):
6567
result = foodstandartsagency.getData(name, location, format)
6668
return jsonify(result)
6769

70+
#Gets the crime categories from the police api
71+
@external_api.route('/api/'+str(servers['police']))
72+
def getCrimeCategories():
73+
result = police.getCategories()
74+
return jsonify(result)
6875

76+
# Gets the neighbourhoods in a county from the police api
77+
@external_api.route('/api/'+str(servers['police'])+'/<county>')
78+
def getNeighbourhoods(county):
79+
result = police.getNeighbourhoods(county)
80+
return jsonify(result)
6981

82+
# Gets the boundary coordinates for a neighbourhood in a county
83+
@external_api.route('/api/'+str(servers['police'])+'/<county>/<nhood>')
84+
def getBoundary(county, nhood):
85+
result = police.getBoundary(county, nhood)
86+
return jsonify(result)
7087

88+
# Gets the crimes done in this location during that month from the police api
89+
# The date must be a string in the format 'yyyy-mm'
90+
@external_api.route('/api/'+str(servers['police'])+'/<category>/<lat>/<lng>/<date>')
91+
def getCrimes(category, lat, lng, date):
92+
result = police.getCrimes(category, lat, lng, date):
93+
return jsonify(result)
7194

72-
73-
74-
75-
95+
# Gets the crimes done in this area during that month from the police api
96+
# The date must be a string in the format 'yyyy-mm'
97+
@external_api.route('/api/'+str(servers['police'])+'/<category>/<latArr>/<lngArr>/<date>')
98+
def getCrimes(category, latArr, lngArr, date):
99+
result = police.getCrimes(category, latArr, lngArr, date):
100+
return jsonify(result)
76101

77102

index.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ indexes:
99
# manually, move them above the marker line. The index.yaml file is
1010
# automatically uploaded to the admin console when you next deploy
1111
# your application using appcfg.py.
12-
# test

0 commit comments

Comments
 (0)