#! /usr/bin/python # -*- coding:utf-8 -*- from flask import Flask, render_template, request, redirect, url_for app = Flask(__name__) #taches : dictionnaire (tableau associatif) de tâches taches=[] #id : identifiant de la tache id = 1 @app.route('/') def index(): return render_template('index.html', taches=taches) @app.route('/ajout', methods=['POST']) def ajout(): # utiliser les variables globales taches et id global taches, id vartache = request.form['tache'] taches.append({"id":id, "libelle":vartache}) #incrémenter id pour la prochaine tâche id = id + 1 return redirect(url_for('index')) if __name__ == '__main__': app.run(debug=True, port=5005)