Web2py Framework Interview Questions

30+ TOP Web2py Framework Interview Questions Answers

Web2py Framework Interview Questions
Web2py Framework Interview Questions

1) What is Web2py Framework?
Web2py is an open source web application framework. It is written in the Python programming language. It allows web developers to design and develop dynamic web application.

2) How can we Install Web2py in different operating system?
We can install Web2fy in different operating system by using following code:

Operation System:
Unix and Linux

python web2py.py
open web2py.app

3) What are the protocols supports in Web2py?
Web2py supports various protocols like: XML, JSON, RSS, CSV, XMLRPC, JSONRPC, AMFRPC, and SOAP.

4) How to write a hello world program in Web2py?
We can write a hello world program by using following code:

def hello():
return ‘Hello World’

5) Who is the author of Web2py?
Massimo Di Pierro developed the author of Web2py.

6) What is the stable version of Web2py?
Web2py stable version is 2.14.6 which is released on May 10, 2016.

7) How can we represent MVC (Model-View-Controller) in Web2py?
In Web2fy, we can represent MVC (Model-View-Controller) as follows-

Model: It includes the logic of application data. It is used to database connections by configuring storage.sqlite files.

“db.py” is the model:
db = DAL(‘sqlite://storage.sqlite’)
db.define_table(employee, Field(‘name’), Field(‘phone’))

View: View displays the output after the associated controller function is executed. It renders the variables in the dictionary, which is in the form of HTML. It uses {{ and }} delimiters to include the file.

{{extend ‘layout.html’}}
<h1>Manage My Employees</h1>

Controller: It helps to access the functions and modules. It acts as intimidator between Model and View.

def employees():
grid = SQLFORM.grid(db.contact, user_signature = False)
return locals(

8) What are the application components of web2py ?
Web2fy consists of the following components.

Models: It represents data and database tables.
Views: It helps rendering the display of the data.
Controllers: It describes the application logic and workflow.
Languages: describe how to translate strings in the application into various supported languages.
Static files: Do not require processing (e.g. images, CSS style sheets etc).
ABOUT and README: It provide details of the project.
Errors: It stores error reports generated by the application.
Sessions: It stores information related to each particular user.
Databases: It store SQLite databases and additional table information.
Cache: It store cached application items.
Modules: Modules are other optional Python modules.
Private: It includes files are accessed by the controllers but not directly by the developer.
Uploads: Files are accessed by the models but not directly by the developer.

9) Which class is used to send email in Web2py Framework?
In Web2fy Framework, gluon.tools.Mail class is used to send email. The mailer can be defined with this class.

from gluon.tools import Mail
mail = Mail()
mail.settings.server = ‘smtp.example.com:25’
mail.settings.sender = ‘abc@example.com’
mail.settings.login = ‘username:password’

10) What is the default port of Web2py?
Web2py default port is 8000.

11) What is Postbacks?
A better pattern in web2py is to submit forms to the same action, which generates them. This mechanism is called as “postback” which is the main feature of web2py. In short, self-submission is achieved in postback.

12) How can we create a model?
We can create a model by using following code :

db.define_table(‘company’, Field(‘name’, notnull = True, unique = True), format = ‘%(name)s’)
Field(‘name’, notnull = True),
Field(‘company’, ‘reference company’),
Field(‘picture’, ‘upload’),
Field(’email’, requires = IS_EMAIL()),
Field(‘phone_number’, requires = IS_MATCH(‘[\d\-\(\) ]+’)),
format = ‘%(name)s’

Field(‘body’, ‘text’, notnull = True),
Field(‘posted_on’, ‘datetime’),
Field(‘contact’, ‘reference contact’)

15) Describe the workflow of Web2py?
Web2py workflow are given below :

The web server manages HTTP requests simultaneously in its own thread.
The HTTP request header is passed to the dispatcher.
The dispatcher manages the application requests and map the PATH_INFO in the URL of the function call. Every function call is represented in the URL.
All the requests for files included in the static folder are managed directly, and large file are streamed to the client.
Requests for anything but a static file are mapped into an action.
If the request header contains a session cookie for the app, the session object is retrieved; or else, a session id is created.
If the action returns a value as string, this is returned to the client.
If the action returns an iterable, it is used to loop and stream the data to the client.

16) What are the features of Web2py?
Web2py features are:

It is easy to learn.
It is portable.
It has standard library that supports many task.

17) What is the I/O functions in Web2py?
There are various I/O functions in Web2py that are given below.

open(): It helps to open a file or document
write(): It helps to write a string in file or document
read(): It helps to read the content in existing file
close(): This method closes the file object.

18) What is CRON in Web2py?
In Web2py, CRON gives the ability to run the task within the specified interval of the time.

19) What is RBAC in Web2py?
In Web2py, RBAC stands for Role Based Access Control. It is an approach to restricting system access to authorized used.

20) Which method is used to send an email in Web2py?
In Web2py, mail.send() method is used to send an email.

21) What are the protocols used in Web2py?
There are various protocols used in Web2py:

SOAP etc.

22) Does Web2py support multiple database?
Yes, Web2py supports multiple database.

23) What is the use of DAL object?
DAL object is used to represents a database connection.

Example: db = DAL(‘sqlite://storage.sqlite’)

24) How can we disable all the table in Web2py?
In Web2py, Migration is used to disable all the table.


db = DAL(…, migrate_enabled=False)

25) Is it possible to skip the GUI and start Web2py directory?
Yes, by using command line.

Example: python web2py.py -a ‘your password’ -i -p 8000

26) What is the process to send SMS?
The following code is used to send SMS:

from gluon.contrib.sms_utils
import SMSCODES, sms_email
email = sms_email(‘1 (111) 111-1111′,’T-Mobile USA (abc)’)
mail.send(to = email, subject = ‘test’, message = ‘test’)

27) In which language Web2py was written?
Web2py was written in Python language.

28) What is Nginx?
Nigix is a free, open-source web server. It is used to configure file.

29) How can we delete the records?
We can delete the records by using following code:

crud.delete(db.tablename, id)

30) Which tag is used to escape python code embedded in HTML?
Web2py uses {{…}} tag to escape python code embedded in HTML.

Real Time Web2py Framework Interview Questions