jeudi 4 octobre 2018

Flask does not render my modified page when asked

I have a page with a simple text and a button in a form

<html>
<head>
</head>
<body>
    <h1>JASON</h1>
    <form>
      <button type="submit" formmethod="POST">Activate</button>
      <br>
      <input type="hidden" value="act.12344" name="sub" />
    </form>
</body>
</html>

And this python script

from flask import Flask, render_template, request, redirect

app = Flask(__name__)

@app.route('/atdt', methods=['GET', 'POST'])
def atdt():
    if request.method == 'POST':
        print('post')
        requested = request.form['sub']
        ver = str(requested).split('.')
        if ver[0] == 'act':
            print('act')
            modif(ver[1])                        #this func modifies the index page
            return render_template('index.html')

    else:
        return render_template('index.html')

The point of the script is to change the name jason in something else...and it works well, the page is changed and its all good

But my flask program wont show it...the '.html' page its changed, and if I open it manually, outside the program it works!

But if i give python the line return render_template('index.html') but it wont render it If i try to refresh manually it will just show me the old page

Any help ?




Aucun commentaire:

Enregistrer un commentaire