Leverages Google Geo location and Geo coder API to create RESTFUL endpoints for latitude and longitude data given a physical address
Is an virtual environment which will let configure different python projects easily and manage dependencies much simpler.
Pip is a package management system used to install and manage software packages, such as those found in the Python Package Index. Although pip isn't necessary it is highly recommended for local development
Docker allows for containerized applications.
Local development can be done using requirments.txt
virtualenv <project_name>
source <project_name>/bin/activate
pip install -r requirements.txt
EXPORT GOOGLE_API_KEY=<YOUR_GOOGLE_KEY>
EXPORT GEOCODER_APP_ID=<YOUR_GEOCODER_APP_ID>
EXPORT GEOCODER_APP_CODE=<YOUR_GEOCODER_APP_CODE>
This is needed for docker
GOOGLE_API_KEY=<YOUR_GOOGLE_KEY>
GEOCODER_APP_ID=<YOUR_GEOCODER_APP_ID>
GEOCODER_APP_CODE=<YOUR_GEOCODER_APP_CODE>
python geolocation/__init__.py
Now the application will be running on localhost and port 3000
v1/geolocation
{
"data": [
{
"latitude": 39.66154,
"longitude": -124.49674
}
]
}
curl v1/geolocation?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
curl --data "address=1600 Amphitheatre Parkway,Mountain+View,CA" v1/geolocation
The tests require the package of geolocation be available for use. Use setup.py to achieve this
pip install --editable .
And than we can run the tests
python tests/test_geolocation.py
With docker we can build the image locally and run it however, the image is already in a public docker repo so we can just simply run it with updated values in main.env
docker run -d --env-file=main.env -p 4000:3000 hskalee123/geolocation:latest
docker build -t geolocation .
docker run -d --env-file=main.env -p 4000:3000 geolocation
curl --data "address=1600 Amphitheatre Parkway,Mountain+View,CA" localhost:4000/v1/geolocation