Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

282
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda