File tree 4 files changed +8
-11
lines changed
4 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 1
1
# View crime statistics in the UK!
2
2
A flask powered app, with data visualisation using D3.
3
+
4
+ ![ ScreenShot] ( ScreenShot.png )
Original file line number Diff line number Diff line change 8
8
< body class ="body ">
9
9
< h1 > Welcome to the UK Crime Stats site</ h1 >
10
10
< form action ="{{ url_for('viewcrime') }} " method ='POST '>
11
- < input type = 'text ' name ='location ' placeholder ='Enter a UK address ' id = 'location '>
11
+ < input type = 'text ' name ='location ' placeholder ='Enter a UK postcode ' id = 'location '>
12
12
< button type ="submit " id ="submit_button " class ="button-styling "> Get stats</ button >
13
13
</ form >
14
14
</ body >
Original file line number Diff line number Diff line change @@ -41,16 +41,11 @@ def home():
41
41
42
42
43
43
def get_data (location ):
44
- KEY = read_json ('params.json' , 'MAPQ' )
45
- url1 = 'http://open.mapquestapi.com/geocoding/v1/address?'
46
- params1 = dict (
47
- key = KEY ,
48
- location = location
49
- )
50
- resp1 = requests .get (url = url1 , params = params1 )
51
- ll = json .loads (resp1 .text )['results' ][0 ]['locations' ][0 ]['displayLatLng' ]
52
- latitude = ll ['lat' ]
53
- longitude = ll ['lng' ]
44
+ url_postcode = "http://api.postcodes.io/postcodes/" + location
45
+ resp_postcode = requests .get (url = url_postcode )
46
+ ll = json .loads (resp_postcode .text )['result' ]
47
+ latitude = ll ['latitude' ]
48
+ longitude = ll ['longitude' ]
54
49
url = 'https://data.police.uk/api/crimes-street/all-crime?'
55
50
params = dict (
56
51
lat = latitude ,
You can’t perform that action at this time.
0 commit comments