diff --git a/app/app.py b/app/app.py index 7fcceb0..0ce9441 100644 --- a/app/app.py +++ b/app/app.py @@ -3,8 +3,8 @@ import os from flask import Flask from flask import render_template -#import werkzeug +from .config import secret_key, wtf_csrf_secret_key from .routes import main APPPATH = os.path.dirname(os.path.abspath(__file__)) @@ -21,6 +21,11 @@ app = Flask( "in case we put a trailing slash at the end of the route's uri" app.url_map.strict_slashes = False +app.config.update(dict( + SECRET_KEY= secret_key, + WTF_CSRF_SECRET_KEY= wtf_csrf_secret_key +)) + @app.before_request def clear_trailing(): from flask import redirect, request diff --git a/app/config.py b/app/config.py index 9ca0549..3579bcc 100644 --- a/app/config.py +++ b/app/config.py @@ -19,4 +19,5 @@ with open(local_params_file, 'r') as file_handle: # dbadmin = params_content['dbadmin'] # dbpassword = params_content['dbpassword'] # server_ip = params_content['server_ip'] +# secret_key, wtf_csrf_secret_key """ diff --git a/app/routes.py b/app/routes.py index 10e9afb..8ffc9be 100644 --- a/app/routes.py +++ b/app/routes.py @@ -21,28 +21,44 @@ Then the 'dynamic' (calculated) routes : import typing as t -from flask import Blueprint, abort, render_template, request, send_from_directory +from flask import Blueprint, render_template, request, redirect import folium from pymongo import ASCENDING + from .dbinit import * 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("/") +@main.route("/", methods=('GET', 'POST')) def home(): """home route""" - return render_template("home.html") + form = SearchForm() + if form.validate_on_submit(): + return f'''