def test_write_load(): """Check that the write and load don't change the courses""" courses = load_csv("courses.csv") write_json("courses.json", courses) loaded_courses = load_json("courses.json") eq_(courses, loaded_courses)
from flask import Flask, request, jsonify from process_data import load_json # Now that we've processed the data, let's present it in an API. You can # imagine that this will be used by some frontend, say a website with # Javascript, to display useful information to users. # Stores the global list of course data. All functions in this file should use # this data for their operation. You are free to define other globals, if they # make sense to be used as global variables. COURSES = load_json("courses.json") app = Flask(__name__) # The following functions should return JSON values indicating their results # (or error) # Note that JSON should never have lists at the top level due to security # issues with Javascript. See # http://flask.pocoo.org/docs/security/#json-security for more. # Your return format should look like: # { results: [list of results] } # or # { error: "error description" } # or # { results: { valid: true } } # See what is expected in tests.py if this is unclear