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.

The AIB Research & Innovation Hub showing the Transport Dashboard

I have spoken in the past about learning HTML and JavaScript to build a Dashboard which allowed users to interact with the then recently released Irish 2016 Census. For this short project I decided to reuse much of the work I had previously completed for that project. However, I’m alsways interested in learning new things so I decided to build this Dashboard as a python Flask app in order to learn more about the very useful Flask package.

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
import flask
from flask import Flask
import requests
import xmltodict
import json
app = Flask(__name__)
@app.route('/')
def index():
return flask.render_template('index.html')
#Grab DART data from API and convert to JSON    
@app.route('/dart')
def dart_times():

r = requests.get("http://api.irishrail.ie/realtime/realtime.asmx/getStationDataByCodeXML_WithNumMins?StationCode=LDWNE&NumMins=90")

data = xmltodict.parse(r.text)['ArrayOfObjStationData']['objStationData']
return json.dumps(data)
#Grab Dublin Bus data from API and convert to JSON
@app.route('/bus')
def bus_times():

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']
return json.dumps(data)

Here, the ‘index.html’ file renders the Dashboard and calls both ‘/dart’ and ‘/bus’ to get the relevant DART and Dublin Bus timetables.

The final AIB Transport Dashboard. Any strange disagreements between times is due to the relevant APIs sometimes returning conflicting information!

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!

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.