Python task manager from scratch, part 19: Preparing the way II

We don't just want to look at our tasks in our Web view. We want to change those tasks, too. To do that, we'll add input fields to our Web view for information about a task to be added. (We'll get around to deleting and changing them, too.)

This means we need to know about:

  1. HTML forms
  2. HTTP verbs and how to handle them in Bottle

It's remarkably easy to mess something up here! Good software engineering comes in handy. Here the mantra that popped to my mind is: "Make the change easy, then make the easy change."

So, let's add no new functionality and just distinguish between GET and POST in main.py. My approach here was:

  1. Copy what's currently at '/' to '/add', because the view we have is a reasonable starting point for what an add-task view will look like.
  2. Put in a function intended to handle the POST requests associated with adding tasks. Decorate it the way Bottle requires.
  3. Run Pytest and make sure it doesn't complain.
  4. Fire up the local Web server and make sure the list looks OK (both at '/' and at '/add').

This makes the upcoming change a lot easier, especially if you're less fluent in HTTP and HTML.

Here's the current commit in the veery/ repository.


Home page