Created
March 14, 2022 02:48
-
-
Save cassioeskelsen/de5a0700ba5c3cdc419279f39c7eede3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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