Saying "Hello world" using Masonite Framework
Tags: python, framework, masonite
Published: 2018-06-20 23:15:56

---
title: Saying "Hello world" using Masonite Framework
published: true
description: A pratical guide showing how to get started with The Modern And Developer Centric Python Web Framework.
tags: python,framework,masonite
cover_image: https://images.unsplash.com/photo-1496862831786-3fdc3d8747be?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9d3ff61b517c316a85eecd0b4cdd1565&auto=format&fit=crop&w=1350&q=80
---

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


# What is [Masonite Framework](https://github.com/MasoniteFramework/masonite)?
According to the official [documentation](https://docs.masoniteproject.com/), 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](https://github.com/MasoniteFramework/masonite), 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:
```
http://localhost:8000/
```
Voila!
![Masonite Framework](https://thepracticaldev.s3.amazonaws.com/i/905962zllph6suneyehr.png)

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):
        pass

```
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](https://thepracticaldev.s3.amazonaws.com/i/4lrpc8wzrop48nsuyw5w.png)