def app(): flask_app = Flask(__name__) add_batch_route(flask_app) state = {} @flask_app.route("/cat/<cat>", methods=["GET"]) def get_cat(cat): try: got_cat = state[cat] except KeyError: abort(404) return jsonify(got_cat) @flask_app.route("/", methods=["GET"]) def get_home(): return jsonify(state) @flask_app.route("/cat/<cat>", methods=["PUT", "PATCH"]) def put_home(cat): state.update({cat: request.json}) return jsonify(state.get(cat)) flask_app.debug = True return flask_app
from flask import Flask, request, jsonify from flask_batch import add_batch_route app = Flask(__name__) app.url_map.strict_slashes = False add_batch_route(app) state = {"alice": "hello"} HEADERS = {"Content-Type": "application/json"} @app.route("/cat/<cat>", methods=["GET"]) def get_cat(cat): return jsonify(state.get(cat)) @app.route("/", methods=["GET"]) def get_home(): return jsonify(state) @app.route("/cat/<cat>", methods=["PATCH"]) def patch_cat(cat): state.update({cat: request.json}) return jsonify(state.get(cat)) @app.route("/cat/<cat>", methods=["PUT", "POST"]) def put_home(cat): state.update({cat: request.json})
def batch(): add_batch_route(app)