mark todos as done
1 changed files with 11 additions and 0 deletions
app.py
View File
| @@ -15,3 +15,14 @@ | ||
| 15 | 15 | if title: |
| 16 | 16 | todos.append({"title": title, "done": False}) |
| 17 | 17 | return redirect("/") |
| 18 | + | |
| 19 | + | |
| 20 | +@app.post("/done/<int:index>") | |
| 21 | +def done(index): | |
| 22 | + if 0 <= index < len(todos): | |
| 23 | + todos[index]["done"] = True | |
| 24 | + return redirect("/") | |
| 25 | + | |
| 26 | + | |
| 27 | +if __name__ == "__main__": | |
| 28 | + app.run(debug=True) | |