In my HTML page, I have a button. When I click on the button it should call a Python function that takes a screenshot and save it in the same directory. I tried my Python method and it is working correctly on local. But when I used Flask to call the function from a HTML button, it does nothing and there are no errors. How to get the screenshot image ?
Python Flask:
@app.route('/')
def index():
return render_template('index.html')
# Function to take the screenshot and save it
def takesc():
with mss() as sct:
sct.shot()
@app.route('/takeScreenshot')
def takeScreenshot():
return takesc()
My HTML
<button onclick="{{ takeScreenshot }}">ScreenShoot</button>
I also tried to use 'url_for' as following, but still nothing happened:
<button onclick="{{ url_for('takeScreenshot') }}">ScreenShoot</button>