Ask coding questions

← Back to all posts
How to run python code using an html button (flask)
elipie (364)

Hello, I have been working on a project recently, and I have ran into a problem.

None of the things I google give me clear answers to what I am asking for, so I just had to come to replit to see who could help me.

Just a heads up, I am kind of a noob at flask, so if im not getting something that is the reason.

Some code samples

or questions

The main question is, why doesn't onclick work, or am I just using it wrongly?

<button onclick("")> Click me </button> 



Its supposed to print "Hello" everytime I click the button, to see if its working (ah yes, test runs). But all it does when I run it, is Hello! then all the flask stuff. Why is this? And is there a solution?

Also, you do not have to use onclick for the answer, I just use that for tests a lot.


Coder100 (17133)
<button onclick="... js code here ..."></button>

can't believe i have to explain this

Coder100 (17133)

that's not how you use HTML. It doesn't run python code lol