Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Adjust the following Python file so it also collects: - address - birthdate (prompt for the user to enter in this format: YYYY-MM-DD) - Similarly

Adjust the following Python file so it also collects:

- address

- birthdate (prompt for the user to enter in this format: YYYY-MM-DD)

- Similarly to how it handles name, it should store and get the above variables in the session cookie:

from flask import Flask, render_template, session, redirect, url_for

from flask_wtf import FlaskForm

from wtforms import StringField, SubmitField

from wtforms.validators import DataRequired

from flask_bootstrap import Bootstrap

app = Flask(__name__)

app.config['SECRET_KEY'] = 'hard to guess string'

bootstrap = Bootstrap(app)

class NameForm(FlaskForm):

name = StringField('What is your name?', validators=[DataRequired()])

submit = SubmitField('Submit')

@app.route('/', methods=['GET','POST'])

def index():

form=NameForm()

if form.validate_on_submit():

#we will set up a cookie to store the name

session['name']=form.name.data

#the redirect will help eliminate the refresh warning

return redirect(url_for('index'))

#the following line will get the saved name from the session cookie

return render_template('user5.html', form=form, name=session.get('name'))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions

Question

6. What is accomplished by thinking beyond my own needs?

Answered: 1 week ago