> For the complete documentation index, see [llms.txt](https://docs.masoniteproject.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.masoniteproject.com/v1.5/creating-your-first-blog/part-2-creating-our-first-controller.md).

# Part 2 - Creating Our First Controller

{% hint style="danger" %}
This section is incomplete
{% endhint %}

## Getting Started

All controllers are located in the app/http/controllers directory and Masonite promotes 1 controller per file. This has proven efficient for larger application development because most developers use text editors with advanced search features such as Sublime, VSCode or Atom. Switching between classes in this instance is simple and promotes faster development. It's easy to remember where the controller exactly is because the name of the file is the controller.

You can of course move controllers around wherever you like them but the craft command line tool will default to putting them in separate files.

## Creating Our First Controller

Like most parts of Masonite, you can scaffold a controller with a craft command:

{% code title="terminal" %}

```
$ craft controller BlogController
```

{% endcode %}

This will create a controller in `app/http/controllers` that looks like:

{% code title="app/http/controller/BlogController.py" %}

```python
class BlogController:
    ''' Class Docstring Description '''

    def show(self):
        pass
```

{% endcode %}

Simple enough, right?

Notice we now have our show method we specified in our route.

## Returning a View

We can return a view from our controller. A view in Masonite are html files. It is what the user will see. We can return a view by using the `view()` function:

```python
def show(self):
    return view('blog')
```

Notice here we didn't import anything. Masonite comes with several helper functions that act like built in Python functions. These helper functions make developing with Masonite really efficient.

{% hint style="success" %}
You can learn more about helper functions in the [Helper Functions](/v1.5/the-basics/helper-functions.md) documentation
{% endhint %}

## Creating Our View

You'll notice now that we are returning the `blog` view but it does not exist.

All views are in the `resources/templates` directory. We can create a new file called resources/templates/blog.html or we can use another craft command:

{% code title="terminal" %}

```
$ craft view blog
```

{% endcode %}

This will create that file for us.

If we put some text in this file like:

{% code title="resources/templates/blog.html" %}

```markup
This is a blog
```

{% endcode %}

and then run the server

{% code title="terminal" %}

```
$ craft serve
```

{% endcode %}

and open up `localhost:8000/blog`, we will see "This is a blog"

{% hint style="success" %}
In the next part we will start designing our blog application
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.masoniteproject.com/v1.5/creating-your-first-blog/part-2-creating-our-first-controller.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
