from flask import Flask, render_template, jsonify app = Flask(__name__) # Create an instance of Flask class # At the /quotes route, render quotes.html from templates @app.route('/quotes') def hello_name(): return render_template('quotes.html') # At the /api route, return a JSON representation of the quotes.txt file @app.route('/api') def quotes(): # Read in the file and split it into an array in form # [quote, author, quote, author, etc...] file = open("quotes.txt", "r") input = file.read().replace('\r', ' ').replace('\n', ' ').replace(' ', '--').split("--") # Loop through the entire input array and format it into the array "out" out = [] # YOUR CODE HERE # Close the connection with the file and return the array as JSON file.close() return jsonify(out) # Run the app on the IP address 0.0.0.0, port 8080 with debug mode on if __name__ == '__main__': app.run(host='0.0.0.0', port=8080, debug=True)