import flask import feedtools import json APP = flask.Flask(__name__, static_url_path="", static_folder="static", template_folder="templates") @APP.route("/") def index(): db = feedtools.load() template = flask.render_template( "index.html", db=db, ) return template @APP.route("/API/latest/") def latest(num): request = feedtools.latest(num) response = APP.response_class( response=json.dumps(request), status=200, mimetype='application/json' ) return response @APP.route("/API/today/") def today(): request = feedtools.today() response = APP.response_class( response=json.dumps(request), status=200, mimetype='application/json' ) return response @APP.route("/API/past/") def past(days): request = feedtools.past(days) response = APP.response_class( response=json.dumps(request), status=200, mimetype='application/json' ) return response if __name__ == "__main__": feedtools.update() APP.debug = True APP.run(port=5678)