routing temp

This commit is contained in:
Kadir 2024-01-29 01:09:56 +00:00
parent f30115eecd
commit 5349088ba0
2 changed files with 29 additions and 0 deletions

20
code/routing.py Normal file
View file

@ -0,0 +1,20 @@
import requests
API_KEY = 'AIzaSyBoBHzeQFgR7O-NlNsuHXQcC1B7ccEHpl8'
url = "https://maps.googleapis.com/maps/api/distancematrix/json"
origin = '51.5636306598907,-0.11061106079085892'
dest = "51.53836609846008,-0.12743940233824352"
params = {
"origins": origin,
"destinations": dest,
"key": API_KEY,
"departure_time": "", # timstamp, optional
"mode": "transit",
}
r = requests.get(url, params=params)
print(r.status_code)
print(r.json())

9
code/utils.py Normal file
View file

@ -0,0 +1,9 @@
from datetime import datetime, timedelta, timezone
def nextMonday():
now = datetime.now(timezone.utc)
days_until_monday = (0 - now.weekday() + 7) % 7
monday = now + timedelta(days=days_until_monday)
monday_9am = monday.replace(hour=9, minute=0, second=0, microsecond=0, tzinfo=timezone.utc)
return monday_9am
print(nextMonday())