@app.route("/<topic>/", methods=["GET", "POST"])
@app.route("/<topic>/<group_or_key>/", methods=["GET", "POST"])
def flasfka(topic, group_or_key=None):
    topic = topic.encode("utf-8")
    if group_or_key is not None:
        group_or_key = group_or_key.encode("utf-8")

    client = get_kafka_client()
    client.ensure_topic_exists(topic)

    if flask.request.method == "GET":
        limit = int(flask.request.args.get(
            "limit", app.config["CONSUMER_LIMIT"]
            ))
        group = group_or_key
        return flask.jsonify(consume(topic, group, limit))
    if flask.request.method == "POST":
        key = group_or_key
        data = flask.request.get_json(force=True)
        try:
            produce(topic, data["messages"], key)
            return flask.make_response(("", 204, {}))
        except (__HOLE__, TypeError):
            return flask.make_response((
                'expected format: {"messages": ["message1", ...]}',
                400,
                {}
            ))

# Snippet to attach the version to every request
dataset/ETHPy150Open travel-intelligence/flasfka/flasfka/api.py/flasfka