Javatpoint Logo
Javatpoint Logo

Web2py Framework in Python

In the following tutorial, we will understand the Web2py framework in the Python programming language.

Understanding the Web2py Framework

Web2py is an easy-to-use framework that does not require any installation and configuration. This framework is portable and can also be executed on a USD drive. It is based on the MVC framework like many other Python frameworks. Though most of them do not support older versions of the Python programming language, the Web2py framework still supports versions like Python 2.6 and 2.7. It also supports LDAP for authentication, which is widely accepted these days.

The Web2py framework attempts to lower the barrier of entry to web development by focusing on three chief goals:

  1. Rapid Development
  2. Ease of Use
  3. Security

Acknowledging the perspective of the user, the Web2py framework is developed and constantly being optimized internally in order to make it a faster and leaner framework with the inclusion of the support for backward compatibility.

Setting Up the Environment

Execution of the Web2py framework is easy, and we need to download the .exe file from the following link:

Web2py Framework in Python

For Windows, we can download the ZIP file, unzip it, and execute the .exe file either directly or from the command line. We will be prompted with the screen asking for the admin password as shown below:

Web2py Framework in Python

We can choose an administrator password and start the server. We will see the following screen:

Web2py Framework in Python

Creating an application using Web2py

Let us now create a new application with the help of the Python Web2py framework. We will start by clicking on the admin table located at the bottom. So, after entering the admin password, we will have the following screen:

Web2py Framework in Python

Now, go to new simple application, enter some application name (for example, introWeb2py) and click on create. This will display design interface page as shown below:

Web2py Framework in Python

We can also go to the current live web, introWeb2py, and simply type on the local machine, and we will get the output as shown below:

Web2py Framework in Python

In the design page of the introWeb2py application, we will go to the controller and click on the edit button next to If we alter the return value of the index() function, the following output will be displayed.


Now, let us save the changes. We can check the changes made in the introWeb2py application by refreshing the link. The output for the same is shown below:


Web2py Framework in Python

Deployment of the application on the Cloud platform

If we want to deploy the application on the Cloud platform, we will go back to the home page and click on the site. We can select any option for deployment. Here, we will select "pythonAnywhere". We will then go to the pythonAnywhere website and register ourselves (if not done already). We will then click on "Add a new web app" and fill in all the credentials (Select web2py app). That's it.

We will go to, and click on the admin tab (enter password). Next, we will click on upload and install the packed application. We have to fill in the credentials below and click install.

Once everything is completed, a pop-up message will appear. In order to view the application, open the below link: and we can see the following screen.


Web2py Framework in Python

Hence, the first web2py application is created and deployed successfully.

At last, we can conclude the Web2py framework is a free, fast, secure web development framework that is entirely written in the Python programming language and encourages with the help of Python in every way possible (model, view, controller). It is a very good framework for small web applications or prototypes; however, it fails to fulfill the enterprise-class quality requirements. In an enterprise-level application, the complexity of solving bugs will increase exponentially due to the lack of unit tests, good and accurate error reporting, and scattered models.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA