try {
String path = request.getPathInfo().toLowerCase();
if (path.contains("/api/airportcodes")) {
// Outputs the airport codes
AirportCodes ac = AirportCodes.getInstance();
res = ac.getCodes();
} else if (path.contains("/api/airportcodebycity/")) {
// Gets Airport by City
int x = path.lastIndexOf("bycity/") + 7;
String p = path.substring(x);
log.info("Get Airport Code by City : " + p);
AirportCodes ac = AirportCodes.getInstance();
String code = ac.getCodeByCity(p);
res.put("code", code);
} else if (path.contains("/api/airportcodebycityandsate/")) {
// Gets Airport Code by City and State
int x = path.lastIndexOf("/api/airportcodebycityandsate/")
+ "/api/airportcodebycityandsate/".length();
String p = path.substring(x);
String[] par = p.split("/");
log.info("Get Airport Code by City and State : " + par[0] + " "
+ par[1]);
AirportCodes ac = AirportCodes.getInstance();
String code = ac.getCode(par[0], par[1]);
res.put("code", code);
} else if (path.contains("/api/flights/all")) {
// Gets the details of all flights
Flights fs = Flights.getInstance();