Use HAS for calendar

This commit is contained in:
2025-02-09 18:39:31 +00:00
parent 69eacb4f17
commit 9c60f7c37b
6 changed files with 90 additions and 6 deletions

22
hasApi.py Normal file
View File

@@ -0,0 +1,22 @@
import requests
import datetime
from dotenv import load_dotenv
import os
def get_calendar_events():
token = os.getenv('HAS_TOKEN')
if not token:
raise Exception('Missing HAS token')
headers = {"Authorization": f"Bearer {token}"}
payload = {
'start': datetime.datetime.now().strftime('%Y-%m-%d'),
'end': (datetime.datetime.now() + datetime.timedelta(days=14)).strftime('%Y-%m-%d')}
response = requests.get('https://has.nozzy.online/api/calendars/calendar.romosborne_gmail_com',
headers=headers,
params=payload)
return response.json()
if __name__ == "__main__":
load_dotenv()
events = get_calendar_events()