Hello!
I’m studying Flask and experimenting with it and I have some minor questions.
- Let’s say, I want to make a “contact us page”, should I make it with HTML5 or use Flaks’s Web Forms (package name: flask-wtf), Here are some incomplete examples:
class NameForm(FlaskForm):
name = StringField('What is your name?', validators=[DataRequired()])
submit = SubmitField('Submit')
@app.route('/contact', methods=['GET', 'POST'])
def contact():
name = None
form = NameForm()
if form.validate_on_submit():
name = form.name.data
form.name.data = ''
return render_template('contact.html', form=form, name=name)
<form method='POST'>
{{ form.hidden_tag() }}
{{ form.name.label }} <br>
{{ form.name() }} <br>
{{ form.submit() }}
</form>
<form>
<fieldset>
<legend class="form-group">Write your information</legend>
<label for="fullname">Full Name:</label>
<input type="text" class="form-control" id="fullname" placeholder="John Doe">
<label for="email">e-mail address</label>
<input type="email" class="form-control" id="email" placeholder="johndoe@example.com">
<label for="message">Message</label>
<textarea rows="5" class="form-control" id="message" placeholder="Write your message"></textarea>
<br>
<button type="submit" class="btn btn-primary">Send</button>
</fieldset>
</form>
When I should I use each?
( I know examples are incomplete.)
- Flask has also Bootstrap, should I use Flask’s Bootstrap or grab Bootstrap from a CDN and load it from HTML and where it will get downloaded by the client and my server will not have to server Bootstrap?