Cover image for Saying "Hello world" using Masonite Framework

Saying "Hello world" using Masonite Framework

nioperas06 profile image Junior Gantin ・2 min read

In this post, we will build a simple Hello World application using Masonite Framework.

What is Masonite Framework?

According to the official documentation, Masonite is describe as a Python web framework that strives for an actual batteries included developer tool with a lot of out of the box functionality with an extremely extendable architecture. Masonite is perfect for beginner developers getting into their first web applications as well as experienced developers.

Masonite uses the power of Python to offer developers a great set of features such as a simple and expressive routing engine, a powerful command line helpers, a simple migration system, a great Active Record style ORM, a great filesystem architecture for navigating and expanding your project and many more.

Let's begin

In order to use Masonite Framework, you’ll need:

  • Python 3.4+
  • Pip3 or Pipenv

You can now install Masonite using pip:

$ pip install masonite-cli

The next step is to create the Masonite project using craft command line tool:

$ craft new hello_world

This will get the latest Masonite project template inside a folder with the name hello_world. Now run the following commands:

$ cd hello_world
$ craft install
$ craft serve

Open your browser and visit the following address:


Masonite Framework

Masonite is a truly MVC framework. All routes that define which action of which controller will serve are located in routes/web.py.

Now, add the following line in ROUTES list:

Get().route('/home', 'HomeController@home')

In Masonite, you can define a Controller method to a route. Let's create HomeController. Run this command:

$ craft controller Home

All controllers are located in the app/http/controllers directory. The HomeController generated contains:

''' A Module Description '''

class HomeController:
    ''' Class Docstring Description '''

    def show(self):

Just rename show method and return a view:

class HomeController:

    def home(self):
        return view('home')

view is called a helper function that do not require any imports and are simply just available 🔥. Let's create our home template with craft.

$ craft view home

This will create resources/templates/home.html. Change its content:

<h1>Masonite is awesome!</h1>

Open your browser at http://localhost:8000/home and there it is:
Hello world

Posted on Aug 22 '18 by:

nioperas06 profile

Junior Gantin


Software Developer Living In Cotonou, Benin.


markdown guide

hhhhhh this is first time i hear about this framework , it 100% inspired from laravel hhahah