From 9544661dcf0fdba1bb97564a09cda8a5d36192ac Mon Sep 17 00:00:00 2001 From: Nas <94843416+Nasirhus@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:35:13 +0000 Subject: [PATCH 01/13] Shows to do items code --- README.md | 3 +++ todo_app/app.py | 7 +++++-- todo_app/templates/index.html | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e153c3396..280201222 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,6 @@ You should see output similar to the following: * Debugger PIN: 226-556-590 ``` Now visit [`http://localhost:5000/`](http://localhost:5000/) in your web browser to view the app. + +```git remote -v ``` +tells us / lists our remotes diff --git a/todo_app/app.py b/todo_app/app.py index d71780a32..2afa17fe4 100644 --- a/todo_app/app.py +++ b/todo_app/app.py @@ -1,11 +1,14 @@ -from flask import Flask +from flask import Flask, render_template from todo_app.flask_config import Config +from todo_app.data.session_items import get_items + app = Flask(__name__) app.config.from_object(Config()) @app.route('/') def index(): - return 'Hello World!' + items = get_items() + return render_template('index.html', html_items = items) diff --git a/todo_app/templates/index.html b/todo_app/templates/index.html index d6f8d9c85..a9e9d5384 100644 --- a/todo_app/templates/index.html +++ b/todo_app/templates/index.html @@ -12,6 +12,11 @@

To-Do App

Items

From 7f3726ba52d1d07bc496bbdebecad6713f344a79 Mon Sep 17 00:00:00 2001 From: Nas <94843416+Nasirhus@users.noreply.github.com> Date: Fri, 15 Dec 2023 14:56:44 +0000 Subject: [PATCH 02/13] Completed M1 --- todo_app/app.py | 14 ++++++++++++-- todo_app/templates/index.html | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/todo_app/app.py b/todo_app/app.py index 2afa17fe4..5c99596dc 100644 --- a/todo_app/app.py +++ b/todo_app/app.py @@ -1,8 +1,10 @@ -from flask import Flask, render_template +from flask import Flask, redirect, render_template, request from todo_app.flask_config import Config -from todo_app.data.session_items import get_items +from todo_app.data.session_items import get_items, add_item + + app = Flask(__name__) app.config.from_object(Config()) @@ -12,3 +14,11 @@ def index(): items = get_items() return render_template('index.html', html_items = items) + +@app.route('/', methods = ["POST"]) +def new_todo(): + todo = request.form.get("user todo") + item = add_item(todo) + return redirect('/') + + \ No newline at end of file diff --git a/todo_app/templates/index.html b/todo_app/templates/index.html index a9e9d5384..6ee8dd7f8 100644 --- a/todo_app/templates/index.html +++ b/todo_app/templates/index.html @@ -10,6 +10,10 @@

To-Do App

Items

+
+ + +