I'm building a web app right now that has a couple of text-fields that I would ideally like to be able to copy (individually) using a "copy" button next to each field. Right now I'm attempting to write a Pyperclip function in my main file, and then passing that as an onclick
value for a button, but as soon as the page loads, the Pyperclip function executes and my clipboard is updated without pressing anything. So for example:
@app.route('/converted.html', methods = ['GET', 'POST'])
def converted():
pyperclip_Test = pyperclip.copy("apple")
return render_template('converted.html',
pyperclip_Test = pyperclip_Test)
Then in my template file:
<a href="#" onClick = "{{ pyperclip_Test }}; return false">Test</a>
<div>Data that I want to copy</div>
I know the pyperclip function isn't copying that div - I retracted the original data that I can pass - but the problem still remains that the script executes without me pressing the button.
Any idea on how to get this working?