[server]: Add return_luas_data

This commit is contained in:
2025-03-02 21:05:54 +00:00
parent 97486eeed3
commit 88a6f61bd0
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import xmltodict
import json
import os
import requests
def lambda_handler(event, context):
try:
luas_stop_code = event['queryStringParameters']['luasStopCode']
response = requests.get(f"http://luasforecasts.rpa.ie/xml/get.ashx?action=forecast&stop={luas_stop_code}&encrypt=false")
xml_dict = xmltodict.parse(response.text)
return {
'statusCode': 200,
'body': json.dumps(xml_dict)
}
except Exception as e:
return {
'statusCode': 500,
'body': json.dumps({'error': str(e)})
}

View File

@ -0,0 +1,9 @@
#!/bin/sh
API_URL="https://3fzg2hdskc.execute-api.us-east-1.amazonaws.com/return_luas_data"
if [ "$1" ]; then
query_string="?luasStopCode=$1"
fi
curl "$API_URL$query_string"