Skip to content

Instantly share code, notes, and snippets.

@cassioeskelsen
Created March 14, 2022 02:48
Show Gist options
  • Save cassioeskelsen/de5a0700ba5c3cdc419279f39c7eede3 to your computer and use it in GitHub Desktop.
Save cassioeskelsen/de5a0700ba5c3cdc419279f39c7eede3 to your computer and use it in GitHub Desktop.
@app.route("/vote", methods=['POST'])
async def vote(request):
choice = randrange(3)
async with redis.conn as conn:
await conn.rpush("votos", json.dumps(
{"ip": request.ip, "user-agent": request.headers['user-agent'], "body": f"choice={choice}"}))
return response.json(
{'message': 'Voto Recebido'},
status=202
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment