Create a simple web interface for a to-do list application

Assignment Help Python Programming
Reference no: EM132189464

Web Development with Flask

Overview

This week we reviewed the Flask web development framework, and learned some of the basics that goes into creating a Flask project. For this assignment, you will be asked to create a simple web interface for a To-Do list application, using what was learned in the reading for this week.

Useful Reminders

1. Read the assignment over a few times. At least twice. It always helps to have a clear picture of the overall assignment when understanding how to build a solution.

2. Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard.

Background

For this assignment, you are to deliver a Flask application that provides a simple To Do List application. A typical To Do List application allows a user to keep a list of important tasks that they want to keep track of. In our application, a "To Do" item simply consists of:

- a short string describing the task, like "Buy Milk"
- an email address of the person responsible for the task
- a priority level, either Low, Medium or High

The application will consist of a few controllers. The first one is located at the '/' route, and will be responsible for showing the current list of To Do items in a HTML table, and showing an HTML form to submit a new To Do list item. The second controller, located at the '/submit' route, will accept data from the HTML form, add the To Do list item to a global list of items, and redirect back to the first controller. The last controller will be located at '/clear, which will be responsible for clearing the list of To Do items, and redirecting back to the first controller.

The project should be in a file called todoapp.py, and should be runnable by executing: python todoapp.py
The server should then be accessible from a web browser via the URL https://localhost:5000. The following instructions will describe how the application should work.

Part I - Basic Web App Setup

First things first, create a file called todoapp.py that has a boilerplate Flask application, like the "Hello World" example, reproduced below:

from flask import Flask app = Flask( name )
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__': app. run()
Assuming Flask is installed in your Python installation, running python todoapp. py should result in "Hello World" being displayed. You should base the rest of the assignment on this code

Part II - First Controller: View List of To Do Items
Our first controller that we are going to create is the controller responsible for showing the current list of To Do items. This controller should be accessible from the '/' route. For this part, you are going to have to create a list that will store these To Do items. This is similar to the email list in the Flask Tutorial from this week's reading.

Next, you need to create an HTML template that displays this list of To Do items in a table (well add more to this template in later parts). At the outset, this list will be empty, so for debugging purposes, you can create a 'fake' list of To Do items, so you can confirm that your template displays the To Do items correctly. However, make sure you clear the list before submitting a final version of your code.

Part III - Expanding the First Controller: New To Do Item Form
Once you confirm that your controller is displaying the items correctly, we need to expand on the HTML template to display a form that will be used to allow a user to submit a new To Do list item. This form should consist of the following inputs:
- a textbox input used to capture the task itself, with a name of 'task'
- another textbox input used to capture the task's email, with a name of 'email'
- a drop down box allowing the user to choose from 'Low', 'Medium' or 'High' difficulty, with a name of 'priority'
- a submit button with the label 'Add To Do Item'
Remember, this form needs to submit this data to the '/submit' controller, which we will build next. Until we build it, the form will not work. For this part, just focus on creating the form itself.

Part IV - Second Controller: Submitting a New Item

Now we need to create a controller for the HTML form we just created. This controller should be connected to the '/submit' URL. This controller needs to do the following:
- Receive the three input items from the form
- Do some data validation:
o Confirm that the email input is indeed an email (HINT: think back to Week 3)
o Confirm that the priority input value is either 'Low', 'Medium' or 'High'
o On any error, the controller should redirect back to the 'I' controller (without adding anything to the list). Optionally, you can then display an error message to indicate to the user why the submission failed.
- If there are no errors, the controller should append a new To Do item to the list
- Redirect to the main controller
At this point, you should now be able to type in a new To Do item, hit the submit button and see the new To Do item rendered in the HTML table.

Part V - Third Controller: Clear the List

The last controller is responsible for clearing the list and should be routed to the '/clear' URL. Upon being invoked, the list that stores the To Do items should be emptied and set back to an empty list. It should then redirect back to the main controller. To invoke this controller, we need to also add a new HTML form to the first controller that submits to this '/clear' controller. This form should just consist of a submit button (and for clarity, the button should display the text 'Clear')

Extra Credit I - Save the List

One of the downsides to not using a persistent data store, like a relational database, is that this list will be cleared when you restart the daemon. To alleviate this, edit your application to introduce a new form and submit button called 'Save' to the main HTML form. When invoked, the application should save the list to a file, using either the pickle module, or by saving to a file manually. Also, the application should, upon starting, check if that file exists. If it does, load the file and initialize the list as appropriate. If the file does not exist, initialize the list to be empty like before.

Extra Credit II - Delete Individual Items

It would be great if our application was able to delete individual items. Update the main HTML template to render each To Do item with a button that is labelled 'Delete'. Clicking this button should invoke a controller that will delete that To Do item from the list. There is a difficulties with doing this, however: How can we tell the controller which To Do item we need to delete? Think about how you can change the application to support this.

Reference no: EM132189464

Questions Cloud

Explain why you selected the given theories : Summarize goals and objectives for personal practicum experiences. Explain why you selected these theories. Support your approach with evidence-based literature
Identify new markets to exploit international business : Identify new markets to exploit international business opportunities including foreign entry strategies and international location of production.
Managerial approach-hierarchical versus decentralized : Describe the benefits of each managerial approach, Hierarchical versus Decentralized.
What is red and white net income : What is Red and White's net income under variable costing if 1,090 units are sold and operating expenses are $12,800
Create a simple web interface for a to-do list application : Create a simple web interface for a To-Do list application, using what was learned in the reading for week - Flask web development framework
Define comprehensive client assessment of hernandez family : And then address in the comprehensive client assessment of the Hernandez family the following: History of abuse and/or trauma.
What could be the possible risks associated : What could be the possible risks associated with an Enterprise Resource Planning system (ERP).
Discuss the three diagnostic models available to help : Identify the recent developments in technology affecting business and propelling globalization.
Does locking down mobile device operating systems : Does locking down mobile device operating systems make those devices more secure than older, more traditional operating systems of the past?

Reviews

len2189464

12/9/2018 10:26:51 PM

Web Development with Flask (1/2) Quick Overview - Python 2.7 For this assignment, you will be asked to create a simple web interface for a To-Do list application, using what was learned in this reading for this week (see additional details on scanned documents).

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd