https://github.com/crazyoptimist/google-directions-django
Google Directions API integration with Django Rest Framework
https://github.com/crazyoptimist/google-directions-django
Last synced: 8 months ago
JSON representation
Google Directions API integration with Django Rest Framework
- Host: GitHub
- URL: https://github.com/crazyoptimist/google-directions-django
- Owner: crazyoptimist
- Created: 2023-02-17T10:20:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-25T08:11:26.000Z (about 3 years ago)
- Last Synced: 2025-02-05T22:59:04.355Z (over 1 year ago)
- Language: Python
- Size: 36.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Toohla REST API
[](https://github.com/crazyoptimist/google-directions-drf-poc/actions/workflows/test.yml)
### What is this?
This is a RESTful service when a user inputs their origin and destination into the client which returns the carbon emissions, distance, and the time of travel for each mode of transportation:
- Driving
- Walking
- Taking the train
### Design
- Origin and destination incomes as latlng
- Pass the data to Google directions API, to get `distance` and `time` for each transport mode
- Calculate carbon emissions based on the `distance` and the existing emissions data(assume it's fetched by a scheduled worker, for example, running nightly)
- Compose a response and send to the client
- Another endpoint in the same procedure but with origin and destination as address, instead of latlng
### Run
- Create dot env by `cp .env.example .env` and configure with proper values
- Run by `docker compose up -d`
### Development
- Create a virtualenv in your favorite way
- Install dependencies by `pip install -r requirements.txt`
- Install git pre-commit hooks by `pre-commit install`
- Run the dev server by `python manage.py runserver`
### Test
- Run unit tests by `python manage.py test -v 2`
### API documentation
Automatic swagger API documentation is configured, and you can find it by browsing `BASE_URL/swagger` in `development`.
In production, run `python manage.py collectstatic` for generating API docs static files, and configure the production web server(nginx or caddy etc) to serve the static files in a desired path.