English 中文(简体)
Web2py Framework
  • 时间:2024-12-22

Web2py Framework


Previous Page Next Page  

Web2py is an easy-to-use framework. With web2py, no installation and configuration is required as it is portable and can be run on a USD drive too. It is based on the MVC frameworks pke many other python frameworks. Though most of them do not support older versions of Python, web2py still supports older versions: python 2.6 and 2.7. It also supports LDAP for authentication which is widely accepted these days.

Web2py tries to lower the barrier of entry to web development by focusing on three main goals −

    Rapid development

    Ease of use

    Security

Keeping in mind the user perspective, Web2py is built and constantly being optimized internally to make it a faster and leaner framework including support for backward compatibipty.

Instalpng and Configuring Web2py Framework

Running a web2py is easy, you need to download the exe from the below pnk: http://www.web2py.com/init/default/download

For windows, you can download the zip file, unzip it and run the exe file either directly or from the command pne. You will be prompted with below screen asking for the admin password.

Web2py Framework

You can choose an administrator password and start the server. You will see the following screen −

Administrator Password

Creating an app using Web2py

Now we are ready to create a new app. Cpck on the admin tab located at the bottom. So after entering the admin password, we will get the below screen −

Web2py Administration

Go to new simple apppcation, enter some apppcation name (pke helloWeb2py) and cpck on create. This will display design interface page as given below −

Hello Web2py

You can also go to your current pve web,helloWeb2py, simply type http://127.0.0.1:8000/helloWeb2py on your local machine, you will get the below output −

Welcome page

In the design page of helloWeb2py apppcation, go to the controller and cpck on edit button next to default.py. If you change the return value of the index() function, the following output will be displayed −

Index Page

Save the changes, and now you can check the changes made in your helloWeb2py app. Just refresh the http://127.0.0.1:8000/helloWeb2py pnk and you will see the below output −

Web2py Url

Deploying the app on cloud platform

Now if you want to deploy your app on cloud platform, come back to your home page and cpck on the site. You can choose any option for deployment. Here, we choose “pythonAnywhere”. Go to pythonAnywhere website and register yourself (if not already done). Cpck on “Add a new web app” and fill all the credentials (Choose web2py app). All done.

Now go to https://username.pythonanywhere.com/welcome/default/index, cpck on admin tab (enter password). Next cpck on upload and install packed apppcation. Fill the credentials as below and cpck install.

Cloud Platform

Once everything is done, a pop-up message will appear as given below −

Popup Message

Now to view your app, open the below pnk −

https://username.pythonanywhere.com/welcome/default/index and you can see the following screen −

Deploying App

Our first web2py apppcation is successfully created and deployed.

To summarize, Web2py is a free, fast, secure web development framework that is entirely written in python and encourages using python in every way possible (model, view, controller). It is a very good framework for small web apppcations or prototypes but fails to fulfil the enterprise class quapty requirements. It is because, in an enterprise level apppcation, the complexity of solving bugs will increase exponentially because of the lack of unit tests, good and accurate error reporting and scattered model.

Advertisements