def graph_flights(): origin = request.args.get('origin') dest = request.args.get('dest') dept = request.args.get('dept') ret = request.args.get('ret') dept = datetime.strptime(dept, '%m-%d-%Y') ret = datetime.strptime(ret, '%m-%d-%Y') flight_scraper = FlightScraper(origin, dest, dept, ret) # flight_scraper.origin = origin # flight_scraper.destination = dest # flight_scraper.depart_date = dept # flight_scraper.return_date = ret solutions = flight_scraper.solutions() length = len(solutions) return render_template('graph.html', json_obj=graph_prices(flight_scraper), solutions=solutions, lengthSol=length)
def graph_weekly(): origin = request.args.get('origin') dest = request.args.get('dest') dept = request.args.get('dept') ret = request.args.get('ret') start_date = datetime.strptime("1-1-2013", '%m-%d-%Y') until_date = datetime.strptime("12-31-2013", '%m-%d-%Y') weekdays = map(int, [4,6]) #Can probably use dateutils parser for this. freq=DAILY date_pairs = generate_date_pairs(freq, weekdays, start_date, until_date) result = list() for d in date_pairs: flight_scraper.depart_date = d[0] flight_scraper.return_date = d[1] result.append(graph_prices(flight_scraper)) return render_template('graph_weekly.html', graphs=result, length=len(result))