April 25, 2016 4:34 am

Python: A shareable Todo lists/notes web app with web2py Part 1

Python is the 2nd most popular language out there according to http://pypl.github.io/PYPL.html. With it, you can build plenty of things such as desktop apps, games, viruses, you can use it for server-side programming and so on.

Learning Python a shareable Todo lists-notes web application with web2py

The application that we are going to build serves the purpose of exploring how you can actually craft rapidly a web application in Python. In it, users are generated an identifier which is saved in their session and the session itself is kept alive across browser sessions. Users can delete and create new notes/todo items and they can view the todo lists of other people if those people share their identifier with them.

Figure 1: A demo of the web application

A demo of the web application

In building the application, we are going to use web2py which is a full-stack MVC framework for Python. You can learn how to use it at: http://www.web2py.com/book/default/chapter/01

If you are just about to learn Python, the PyCharm IDE is a good software to get started fast with Python. You can download it from: https://www.jetbrains.com/pycharm/download/#section=windows

You can download web2py from: http://www.web2py.com/init/default/download. After downloading, all you have to do is start web2py.exe

It has to be noted that the application does not take advantage of some patterns at this point (such as using the M (model) in the MVC pattern)

The views

After you have installed web2py, your web applications would be in the applications folder in the folder where you have installed web2py. You can create a new application from the administrative UI of the welcome web application which will appear after you start the web server from web2py.exe

For our purpose, we create a new folder in the applications folder called todo.

We have one main view which we show to users, it is called index.html and it is located in the applications/todo/views/default folder. The default folder is the name of our action, all of our routes would be located on the default action and they will just carry out different logic and redirect us to the home route. Therefore, our main route is going to be /todo/default/index but we will also have other routes (which redirect) again in the default controller/action.

Index.html (our view)

Our index view extends another view file called layout.

Layout.html (the template)

The layout template just spits out some essential markup and creates two entry points: navigation  and content. The index view then just inserts content in these entry points. The layout also displays potential messages coming from our controller.  The index view inserts the actual navigation in the respective navigation block and inserts several files for the content block/entry point.

Add-item.html (Included file)

The above file just inserts a form to add a new note/todo item.


This file just displays a session message coming from our controller and deletes it


This file checks if there are notes to display and displays them in a list. It also adds a form for deleting notes when you click on the remove icon and displays the currently viewed identifier or states that you are viewing your own todo list if an identifier is missing from the session.


Now, it is time to go through some Python code by making the controllers that will handle saving, viewing and removing the notes.

Author Ivan Dimov

Ivan is a student of IT, a freelance web designer/developer and a tech writer. He deals with both front-end and back-end stuff. Whenever he is not in front of an Internet-enabled device he is probably reading a book or traveling. You can find more about him at: http://www.dimoff.biz. facebook, twitter

Tutorial Categories:
  • Sifizm

    Great write up