Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
MVC in Web2Py
3.
How to say hello in Web2py?
4.
Frequently Asked Questions
4.1.
Which is better, web2py or Django?
4.2.
What are Django and Flask?
4.3.
What is the web2py framework?
4.4.
What is pylon framework?
4.5.
What is Falcon API?
5.
Conclusion
Last Updated: Mar 27, 2024

How to say hello in Web2py?

Author Ankit Mishra
1 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Web2Py is written in Python and programmable in Python. Web2py is a free, open-source web framework for the agile development of secure database-driven online applications. As a full-stack framework, web2py has every element required to create entirely working web applications.  There are many such applications of Web2py, though we are here to discuss a basic example of Web2Py as seen in the title of the Blog. So let's get straight into it.

MVC in Web2Py

The Model View Controller (MVC) pattern is one of the guiding principles for software engineering that web2py is intended to help web developers adhere to. The data presentation (the view) and data representation (the model) are separated by web2py, along with the application logic and workflow (the controller). Each of these three components may be designed, implemented, and tested separately with the help of web2py's libraries, which also enable them to function together. Web2py comes with a Database Abstraction Layer (DAL) that automates the dynamic writing of SQL, so the developer doesn't have to. For SQLite, MySQL, PostgreSQL, MSSQL, FireBird, Oracle, IBM DB2, Informix, and Ingres, the DAL can create SQL transparently.

When operating on the Google App Engine (GAE), the DAL can produce function calls for the Google Datastore. We support more databases experimentally, and more are always being added.Web2py automatically creates a fully functional web-based database management interface to access the database and the tables once one or more database tables have been configured. As we now understand the data representation and its key factors. Let’s start our today’s topic of discussion.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

How to say hello in Web2py?

Let's understand this with an example here, as an illustration, we will create a straightforward web application that says to the user, "Hello from Coding Ninjas." This programme will be referred to as "codingNinjas_app". Thinking about how to start? 

Simply start the server from the web2Py.exe application. 

Doing the above will start your Local host and may ask for the password as shown below.

Kindly enter the same password as you have entered in the above.

Enter the name of the new application in the form in the site's admin section at the top right to create it.

After you have entered the Application name and hit the Create button new window of your application console will open, as shown below.

 

To run the new application, visit:

http://127.0.0.1:8000/codingNinjas_app


You now have a copy of the welcome application from Web2Py.  Click on the edit button for the freshly generated application to edit.

You can see what's inside the application on the edit page. There are specific files that make up any web2py application, and the majority of them fall into one of the six categories:

Models: describe data representation.

Controllers: describe application logic and workflow.

Views: describe data presentation.

Languages: describe how to translate an application presentation to other languages.

Modules: Python modules that belong to application.

Static files: static images, CSS files, JavaScript files, etc.

Plugins: groups of files designed to work together.

Other file types (database, session, error, etc.) are present in the application. Still, they are not mentioned on the edit page since the application itself creates and modifies them rather than the administrator.

The application's logic and workflow are contained in the controllers. Every URL is converted into a call to one of the controllers' functions. "appadmin.py" and "default.py," two default controllers, are available. 

The database administration interface is provided by appadmin; at this time, we do not require it. When no controller is supplied in the URL, "default.py" is the default controller that is called and that you need to update. The "index" function should be edited as follows:

Code:

def index():
   return "Hello From Coding Ninjas"


The editing Window looks like this,

Go back to the edit page after saving it. To access the freshly created page, click the link to the index.

http://127.0.0.1:8000/codingNinjas_app/default/index

The index action in the codingNinjas_app application's default controller is invoked. The string it returns is displayed for us by the browser. It should look something like this:

I hope you have successfully compiled and made your First Web2Py application. Let’s move to discuss some FAQs.

Frequently Asked Questions

Which is better, web2py or Django?

Due to its smaller size, simpler learning curve, and lack of project-level configuration files, web2py differs from Django. Compared to PHP-based frameworks and Java-based frameworks, web2py has a significantly more straightforward syntax.

What are Django and Flask?

While Django is a high-level web framework for Python, Flask is a micro-framework. As a result, the flask is considerably simpler to comprehend and learn. Both are open-source platforms. However, the flask is more commonly used for lightweight apps than Django. Both are utilized differently and for various purposes.

What is the web2py framework?

Web2py, written in Python and programmable in Python, is described as a free, open-source online framework for agile development that involves database-driven web applications.

What is pylon framework?

Python-based Pylons Framework is an open-source Web application framework. The Web Server Gateway Interface standard is heavily utilized to encourage reusability and divide functionality into independent modules.

What is Falcon API?

For creating reliable app backends and microservices, Falcon is a lightning-quick, lightweight Python web API framework. The framework performs admirably with gevent/meinheld and asyncio (ASGI) (WSGI).

Conclusion

In this article, we have extensively discussed How to say Hello in Web2py and working with a server.

To learn more about Web2Py, see Web2pyWeb2Py initWeb2Py InstallationTroubleshooting, and Application creation.

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Next article
Some Basic Concepts to Web2py Programming
Live masterclass