I'm creating an API using Flask and have the following code:
@app.route('/<major>/')
def major_res(major):
course_list = list(client.db.course_col.find({"major": (major.encode("utf8", "ignore").upper())}))
return json.dumps(course_list, sort_keys=True, indent=4, default=json_util.default)
When viewing /csci/
in the browser, the output looks like this:
[{ "course": "CSCI052", "description": "Fundamentals of Computer Science. A solid foundation in functional programming, procedural and data abstraction, recursion and problem-solving. Applications to key areas of computer science, including algorithms and complexity, computer architecture and organization, programming languages, finite automata and computability. This course serves the same role as HM 60 as a prerequisite for upper-division computer science courses at any of the Claremont Colleges. Prerequisite: 51.", "instructor": "Bull, Everett L.,, Jr.", "name": " Fundamentals of Computer Science", "number": 52, "school": "PO" }]
How do I return this dictionary so that each key and value are on their own line?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…