Flask : Build Contact Form
Published in
3 min readSep 3, 2020
In this post, we will learn how create a contact form using Flask. The result will be like this :
I. Build Contact Form
All script are available on: https://github.com/Faouzizi/flaskCreateContactForms
First of all you need to install flask and flask_wtf using pip : pip install flask flask_wtf.
a. Create our html contact page
Here we will add all fields that we want to retrieve.
<!-- here we add our contact forms -->
{% block content %}
<div class="contact">
<h3>Contact us</h3><!-- Just here i use "url_for" to call the function get_contact.
This function return the html code of our contact page-->
<form action="{{ url_for('get_contact') }}" method=post>
<div>
<!-- name forms -->
<p>
{{ form.name.label }} <br>
{{ form.name(placeholder='Your name') }}
</p>
<!-- email forms -->
<p>
{{ form.email.label }} <br>
{{ form.email(placeholder='Your e-mail ...') }}
</p>
<!-- Subject of your request -->
<p>
{{ form.subject.label }}<br>
{{form.subject(placeholder='Your subject ...')}}
</p>
<!-- Content of your…