If the request method is GET, our function above will render the create_note.html template. If the request method is not equal to GET (In our case, if the request method is not equal to GET, we are assuming that the request method is equal to POST. We are sure that the request method is equal to POST if its not equal to GET because our route only allows GET and POST)

Check the route that we added above and you’ll see this:

methods=["GET", "POST"]

)

Now back to what I was saying, if the request method is not equal to GET, we are retrieving the submitted title and body by the user using request.form[] and passing its values to the title variable and body variable. Next, we are instantiating a Note model and passing the title and body variables into it. The Note instance is passed to the note variable.

What we did here is just add an HTML form that has 2 labels, 2 text boxes and a submit button. The 2 text boxes will allow the user to input a title and a description for the post. We also set the method attribute of the form to POST. If we don’t specify a method, it will use GET since it’s the default.

If you see an error like “Page not found” or “This site can’t be reached”. It’s probably because your server is not running. So make sure to check if the server is running. If it’s not running, run the server using this command while you’re in inside the note_app folder:

While you’re in the create note page, enter a title and a body and then click the create a button. You should be redirected to the same page but now the inputs should now be gone.

Now let’s check if the note has been saved in the database. In this tutorial, we will use a tool named SQLite manager: https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/ . It is a Firefox browser add-on that we can use to manage SQLite databases. Install it and then open your Firefox browser, click tools and then click SQLite manager: