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.
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 is a truly MVC framework. All routes that define which action of which controller will serve are located in
Now, add the following line in
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 Docstring Description '''
Just rename show method and return a view:
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 view home
This will create
resources/templates/home.html. Change its content:
<h1>Masonite is awesome!</h1>