I have code that generates ethereum public and private keys, through flask I display it on a web page, how can I make it so that every time I go to the page or reload the page a new key is generated? Example in the screenshot below. IMAGE (At the moment new keys are generated after restarting the script), code:
from flask import Flask
from secrets import token_bytes
from coincurve import PublicKey
from sha3 import keccak_256
private_key = keccak_256(token_bytes(32)).digest()
public_key = PublicKey.from_valid_secret(private_key).format(compressed=False)[1:]
addr = keccak_256(public_key).digest()[-20:]
address = ('0x' + addr.hex())
privatekey = (' ' + private_key.hex())
app = Flask(__name__)
@app.route('/e')
def e():
return f'{address}' f'{privatekey }'
if __name__ == "__main__":
app.run(debug =True)