diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-03 22:44:24 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-03 22:44:24 +0530 |
commit | f4fc1a9e830ccd2aff3cc82468ee47b2f0e8b448 (patch) | |
tree | a79e14384a2f9a5dfa00820566bfefc7dab241a7 | |
parent | 14f6b5800512af53fb7d1d9bfeeddcce894ecadf (diff) |
added view manager
-rw-r--r-- | app/views/__init__.py | 0 | ||||
-rw-r--r-- | app/views/main.py | 26 |
2 files changed, 26 insertions, 0 deletions
diff --git a/app/views/__init__.py b/app/views/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/views/__init__.py diff --git a/app/views/main.py b/app/views/main.py new file mode 100644 index 0000000..15f7db9 --- /dev/null +++ b/app/views/main.py @@ -0,0 +1,26 @@ +from app import app +from app.forms.app_forms import MyForm +from flask import render_template, flash + +theme = "original" + +@app.route("/") +@app.route("/index") +def index(): + return render_template("index.html") + +@app.route("/ContactUs", methods=['GET', 'POST']) +def contact_us(): + form = MyForm() + if form.validate_on_submit(): + return "Wuhu" + flash_errors(form) + return render_template("contact.html",form=form) + +def flash_errors(form): + for field, errors in form.errors.items(): + for error in errors: + flash(u"Error in the %s field - %s" % ( + getattr(form, field).label.text, + error + ), 'danger')
\ No newline at end of file |