Question: This exercise uses your programming environment to enhance the Web site you created last week with additional functionality to include images, tables and a Form
This exercise uses your programming environment to enhance the Web site you created last week with additional functionality to include images, tables and a Form using Python flask. Specifically, you will add two (2) additional routes allowing a user to register and login to a web site. Additional security considerations include other routes (beyond the register route) will not be accessible until a successful login has occurred.
In addition to the requirements list above the following functionality should be found within your web site on one or more web pages.
Add at least 4 different images. The images should be local in your environment. For example, they should be saved in your environment and referenced similar to this syntax:
- A Table with at least 4 rows and 3 columns.
- A user registration form
- A user login form
- A password complexity should be enforced to include at least 12 characters in length, and include at least 1 uppercase character, 1 lowercase character, 1 number and 1 special character.
The content and topic of the new images, and tables are up to you. How much is required for the user registration is up to you as well. However, the registration and associated login should contain at least a login name and password.
Here is the code I have so far:
app.py file:
# Let's import date function to display the date today in our website from datetime import date # Import required libraries for flask to work from flask import Flask, render_template # Initialize flask, store the flask instance in the app variable app = Flask(__name__) # This is how you declare route in flask # this route will point to http://127.0.0.1:5000/ @app.route('/') def home(): """Let's store the date today to be display in the page""" date_today = date.today() # render_template displays html page # We can indicate what page to show, and pass variables for our html page to use return render_template('index.html', today=date_today) @app.route('/contact_us') def contact_us(): """this route will point to http://127.0.0.1:5000/contact_us""" return render_template('contact_us.html') @app.route('/about_us') def about_me(): """this route will point to http://127.0.0.1:5000/about_us""" return render_template('about_us.html') # this file will only run only if you directly called this python file # e.g python app.py # it also says that this is the starting point of your program if __name__ == '__main__': app.run()
Index.html file:
Python Project 6!
Finding Ice cream for you!
Menu
- Home
- Contact Us
- About Us
Here's our best Ice Cream to eat!
- Vanilla
- Chocolate
- Cookies & Cream
Special discount will be given this week! Don't eat ice cream to fast.
Date today is: {{ today }}
- Find McDonald Ice cream
- Ice cream recipes
- Ben & Jerry
contact_us.html file:
Python Project 6!
Contact us
No info here!
Menu
- Home
- Contact Us
- About Us
about_us.html file:
Python Project 6
About us
Ice Cream !
Menu
- Home
- Contact Us
- About Us
style.css file:
body { margin: 0; padding: 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } .menu { list-style-type:none; } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
