Skip to content

Instantly share code, notes, and snippets.

@CostaFot
Last active March 22, 2026 22:41
Show Gist options
  • Select an option

  • Save CostaFot/e81ea3b67115f752b170691f42a04c4b to your computer and use it in GitHub Desktop.

Select an option

Save CostaFot/e81ea3b67115f752b170691f42a04c4b to your computer and use it in GitHub Desktop.
@app.route("/claps", methods=["GET"])
def get_claps():
data, _ = get_claps_file()
key = normalise_url(request.args.get("url"))
return jsonify({"claps": data.get(key, 0)})
@app.route("/claps", methods=["POST"])
def add_clap():
data, sha = get_claps_file()
key = normalise_url(request.args.get("url"))
data[key] = data.get(key, 0) + 1
save_claps_file(data, sha)
return jsonify({"claps": data[key]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment