lundi 25 mai 2020

Crating an if statement for different html option in Flask (Python)

I have the following options within my HTML template:

  ```<form action="/s" method="POST">
    <div class="form-group">
      <h3>Where to scrape from</h3>
      <select name="articles">
        <option value="">Select Site</option>
        <option value="Guardian">GUARDIAN</option>
        <option value="BBC">BBC</option>

      </select>
    </div>
    <input type="submit" value="Submit" class="btn" />
  </form>```

and at the moment, I can't figure out how to include an if statement to link different options to different templates.

def submit():
    if request.method == 'POST':
        return render_template('scraped.html', s1=summary, s2=summary2)

Here, I would like to create a statement like:

        return render_template('X.html')
        else return render_template('Y.html')

What is the correct syntax to do that? Thanks!

Aucun commentaire:

Enregistrer un commentaire