[server]: Add return_luas_data
This commit is contained in:
21
server/src/functions/return_luas_data/lambda_function.py
Normal file
21
server/src/functions/return_luas_data/lambda_function.py
Normal 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)})
|
||||||
|
}
|
9
server/src/test/return_luas_data/return_luas_data.sh
Executable file
9
server/src/test/return_luas_data/return_luas_data.sh
Executable 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"
|
Reference in New Issue
Block a user