#参考 #https://www.atmarkit.co.jp/ait/articles/1807/31/news042.html #https://www.atmarkit.co.jp/ait/articles/1807/24/news024_3.html from flask import Flask, render_template, redirect, request from todo import ToDoList, init_db app = Flask(__name__) todolist = ToDoList() #appモジュールでFlaskアプリを構築してから、 #それをinit_db関数経由でtodoモジュールに引き渡して初期化を行う init_db(app) @app.route("/") def show_todolist(): return render_template("todo.html", todolist=todolist.get_all()) @app.route("/additem", methods=["POST"]) def add_item(): title = request.form["title"] if not title: return redirect("/") todolist.add(title) return redirect("/") @app.route("/deleteitem/<int:item_id>")
from todo import ToDoList list1 = [] done1 = [] mylist = ToDoList("New", list1, done1) while True: option = int( input("Enter your option \n\ 1.Add new task\n\ 2.Mark task done\n\ 3.View list: ")) if option == 1: taskname = input("Enter name of task: ") mylist.add(taskname) elif option == 2: print("YOUR LIST: ") for i, key in enumerate(list1): print(i + 1, key) donenum = int(input("Enter task number to be marked as done: ")) mylist.mark_done(list1[donenum - 1]) elif option == 3: print("YOUR LIST: ") mylist.see_tasks()