Building a Transport Dashboard for AIB
Many of the thousands of people who work each day at the AIB Bankcentre in Dublin commute to the bank using public transport. The Lansdowne Road Dublin Area Rapid Transport (DART) station is immediately behind AIB Bankcentre and there are a number of Dublin Bus stops in front of Bankcentre near the RDS. The Research & Innovation (R&I)Hub in AIB has a number of TVs were are visible to all AIB staff which often highlight upcoming R&I events and ongoing R&I projects. I decided it would be a good idea to use these TVs to also show upcoming Train and Bus times as this would be a useful very tool which could also attract AIB staff to visit the R&I Hub and find out about our other on-going projects.
Flask is a micro web framework written in Python which is great for developers working on small projects that need a fast way to make a simple, Python-powered web site. It doesn’t seem to be as fully featured “out of the box” as other frameworks such as Django but it was ideal for the simple Transport Dashboard I wanted to build. The entire python script is given below.
#Simple Flask Transport App
from flask import Flask
app = Flask(__name__)
#Grab DART data from API and convert to JSON
r = requests.get("http://api.irishrail.ie/realtime/realtime.asmx/getStationDataByCodeXML_WithNumMins?StationCode=LDWNE&NumMins=90")
data = xmltodict.parse(r.text)['ArrayOfObjStationData']['objStationData']
#Grab Dublin Bus data from API and convert to JSON
r = requests.get("https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=" + str(flask.request.args.get("stop")) + "&format=xml")
data = xmltodict.parse(r.text)['realtimeinformation']['results']['result']
Here, the ‘index.html’ file renders the Dashboard and calls both ‘/dart’ and ‘/bus’ to get the relevant DART and Dublin Bus timetables.
Overall, I very pleased with how this project turned out. People have found the dashboard quite useful and it has definitely been successful at attracting AIB to the R&I Hub. Flask is everything that it claim to be; a simple efficient way to quickly create a function python webserver.
After multiple petitions, the next step for this project is to get the Dashboard hosted on our internal Intranet so everyone will have access to it from their own PCs.
Hopefully, this will be the first of many dashboards we plan to deploy in Bankcentre to benefit our staff. Watch this space for updates!