コード例 #1
0
ファイル: tests.py プロジェクト: cis192s13/hw
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)
コード例 #2
0
ファイル: server.py プロジェクト: cis192s13/hw
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