1 year ago
28 lines549 B
from flask import Flask, redirect, render_template, request | |
| |
app = Flask(__name__) | |
todos = [] | |
| |
| |
@app.route("/") | |
def index(): | |
return render_template("index.html", todos=todos) | |
| |
| |
@app.post("/add") | |
def add(): | |
title = request.form.get("title", "").strip() | |
if title: | |
todos.append({"title": title, "done": False}) | |
return redirect("/") | |
| |
| |
@app.post("/done/<int:index>") | |
def done(index): | |
if 0 <= index < len(todos): | |
todos[index]["done"] = True | |
return redirect("/") | |
| |
| |
if __name__ == "__main__": | |
app.run(debug=True) |