Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
Can I provide some action to a button in HTML using Python Flask?

So, what I am doing is creating a card using Bootstrap that has a movie poster and its name below it. When I hover over the card it shows a button. On clicking the button what I want is it should display information about that movie.

I searched online but couldn't find any way to do this just with python. They involve javascript and ajax. And, I have no idea about javascript.

For, an input bar with a button I know how it works with Flask. We provide action attribute with the form tag and a name attribute with the input tag, then we use request.form in python file.

But, my problem is that it's a card with button, not a form.

Here's that card with button

Here's the code for the card. The Jinja template is for the information I'm getting from the API using Python.

<div class="movie-content">
{% for poster, title in trendingMoviesDetails.items() if not trendingMoviesDetails.hidden %}
  <div class="card" style="width: 15rem;" title="{{title}}" onclick="recommendcard(this)">
    <div class="imghvr">
      <img class="card-img-top" height="360" width="240" alt="{{title}} - poster" src={{poster}}>
      <figcaption class="fig">
        <button class="card-btn btn btn-danger"> Click Me </button>
      </figcaption>
     </div>
    <div class="card-body">
      <h5 class="card-title">{{title|upper}}</h5>
    </div>
  </div>

{% endfor %}

So, what I want is that when we click on that "Click Me" Button, it takes that {{title}} and redirects me to a new page, showing further information about that name. Let's say I want to just print HELLO {{title}}. For example when we click on that Batman Card that I have provided as an image, it redirects me to a new webpage, that displays "Hello The Batman".

I want to do this just with the help of flask and python. This was something related to my problem

But, I don't have much idea about javascript. And also no idea about ajax and jquery.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

use the function for onClick and return or use redirect(url_for('index')) this from flask

try to use this or read about it in https://www.tutorialspoint.com/flask/flask_redirect_and_errors.htm#:~:text=Flask%20%E2%80%93%20Redirect%20%26%20Errors&text=Flask%20class%20has%20a%20redirect,location%20with%20specified%20status%20code.&text=location%20parameter%20is%20the%20URL,browser's%20header%2C%20defaults%20to%20302.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!