diff --git a/app/app.py b/app/app.py index 0ce9441..6354de7 100644 --- a/app/app.py +++ b/app/app.py @@ -22,8 +22,8 @@ app = Flask( app.url_map.strict_slashes = False app.config.update(dict( - SECRET_KEY= secret_key, - WTF_CSRF_SECRET_KEY= wtf_csrf_secret_key + SECRET_KEY= secret_key +# WTF_CSRF_SECRET_KEY= wtf_csrf_secret_key )) @app.before_request diff --git a/app/routes.py b/app/routes.py index 8ffc9be..978f07a 100644 --- a/app/routes.py +++ b/app/routes.py @@ -21,7 +21,7 @@ Then the 'dynamic' (calculated) routes : import typing as t -from flask import Blueprint, render_template, request, redirect +from flask import Blueprint, render_template, request, url_for, redirect import folium from pymongo import ASCENDING @@ -31,34 +31,22 @@ from .helper import make_timeitem_from_filename main = Blueprint("main", __name__, url_prefix="/") -# flask wtforms -from flask_wtf import FlaskForm -from wtforms import StringField, SubmitField -from wtforms.validators import DataRequired - -class SearchForm(FlaskForm): - search = StringField('Recherche', validators=[DataRequired()]) - submit = SubmitField(label=('Rechercher')) - # ______________________________________________________________________________ # routes @main.route("/", methods=('GET', 'POST')) def home(): """home route""" - form = SearchForm() - if form.validate_on_submit(): - return f'''

Welcome {form.search.data}

''' - return render_template("home.html", form=form) + if request.method == 'POST': + search = request.form['search'] + return render_template("form2.html", search=search) + return render_template("home.html") @main.route("/about/", methods=('GET', 'POST')) def about(): """about route""" - form = SearchForm() - if form.validate_on_submit(): - return f'''

Welcome {form.search.data}

''' - return render_template("about.html", form=form) + return render_template("about.html") @main.route("/actes/") diff --git a/app/templates/container.html b/app/templates/container.html index 27aebf4..571c880 100644 --- a/app/templates/container.html +++ b/app/templates/container.html @@ -34,9 +34,8 @@ Contact -
- {{ form.csrf_token }} - + +
diff --git a/app/templates/form2.html b/app/templates/form2.html new file mode 100644 index 0000000..9677a44 --- /dev/null +++ b/app/templates/form2.html @@ -0,0 +1,43 @@ + + + + + + + + +

En travaux

+ +

Résulat du query : {{ search }}

+ + + + + + +