Skip to content

Instantly share code, notes, and snippets.

@tf-taxa
Last active June 19, 2020 21:34
Show Gist options
  • Save tf-taxa/9b6867d534315674c5963853fe1d2c16 to your computer and use it in GitHub Desktop.
Save tf-taxa/9b6867d534315674c5963853fe1d2c16 to your computer and use it in GitHub Desktop.
# millionaire.py
import json
@taxa.route("/submit_value")
def submit():
rawData = json.loads(request.data)
my_id = taxa.globals.getUserCert()
my_value = rawData["value"]
session[my_id] = my_value
response.add("OK")
@taxa.route("/get_results")
def reveal():
rawData = json.loads(request.data)
my_id = taxa.globals.getUserCert()
my_opponent = rawData["opponent"]
if my_opponent not in session:
response.add("Opponent doesn't exist")
return
if session[my_id] >= session[my_opponent]:
response.add("Your value is no less than your opponent")
else:
response.add("Your value is less than your opponent")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment