This PR introduces a basic Flask API that provides a simple routing service. The API is capable of receiving start, end, and car location coordinates as query parameters, performing basic transformations on the coordinates, and returning them as part of a JSON response. The main route implemented is /route.
Key Changes:
Created a Flask application to serve a single route /route.
Implemented the ability to accept three parameters in the API query: start, end, and car locations, each represented as latitude and longitude coordinates.
Applied a simple transformation by adding 10 to both the latitude and longitude of the input coordinates.
The response is a JSON object containing the modified start, end, and car location coordinates.
How It Works:
The API accepts a GET request to the /route endpoint with the following query parameters:
start: A comma-separated string of latitude and longitude coordinates representing the starting point (e.g., start=12.34,56.78).
end: A comma-separated string of latitude and longitude coordinates representing the ending point (e.g., end=34.56,78.90).
car: A comma-separated string of latitude and longitude coordinates representing the car’s current location (e.g., car=45.67,89.01).
The route handler extracts the query parameters, converts the coordinates to floating-point numbers, adds 10 to each of the latitude and longitude values, and then returns the updated coordinates as a JSON response.
Example Usage:
GET Request:
GET /route?start=12.34,56.78&end=34.56,78.90&car=45.67,89.01
The API will be available at http://127.0.0.1:5000/route.
Test the API by making a GET request with the required parameters using tools like Postman, Curl, or directly via a web browser.
Notes:
The transformation (adding 10 to latitude and longitude) is arbitrary and is currently used as a placeholder. Future versions may involve more complex routing logic.
The API is designed for local testing and runs in debug mode for development purposes.
Summary:
This PR introduces a basic Flask API that provides a simple routing service. The API is capable of receiving start, end, and car location coordinates as query parameters, performing basic transformations on the coordinates, and returning them as part of a JSON response. The main route implemented is
/route
.Key Changes:
/route
.start
,end
, andcar
locations, each represented as latitude and longitude coordinates.10
to both the latitude and longitude of the input coordinates.How It Works:
The API accepts a GET request to the
/route
endpoint with the following query parameters:start
: A comma-separated string of latitude and longitude coordinates representing the starting point (e.g.,start=12.34,56.78
).end
: A comma-separated string of latitude and longitude coordinates representing the ending point (e.g.,end=34.56,78.90
).car
: A comma-separated string of latitude and longitude coordinates representing the car’s current location (e.g.,car=45.67,89.01
).The route handler extracts the query parameters, converts the coordinates to floating-point numbers, adds 10 to each of the latitude and longitude values, and then returns the updated coordinates as a JSON response.
Example Usage:
GET Request:
Response:
Testing the API:
http://127.0.0.1:5000/route
.Notes: