<commit_before>
## Actions

The cornerstone of any Espresso app.

Namely, actions are the workhorses that creates the routes to be served by app, as well as running our code.

If we need user to see "Hello World!" when he visits "/hello" address in the browser, we simply do like this:

```ruby
def hello
    "Hello World!"
end
```

It is really straightforward to define actions in Espresso cause they are usual Ruby methods.


**[ [contents &uarr;](https://github.com/slivu/espresso#tutorial) ]**


## Controllers


A controller is meant to organize and setup actions.

The basic setup is base URL. It is defaulted to the controller's undersocred name and are used by all actions.

Other setups are action-specific and can be set for N or for all actions.<br/>
To define a setup for all actions, simply call appropriate method at controller's class level.<br/>
To setup specific actions, call appropriate methods inside `setup` proc that will accept action names as arguments.<br/>
Action names can also be given as regular expressions.

**Example:** - Creating a controller that will serve "/pages/latest" and "/pages/rss" URLs

```ruby
class Pages < E

    # setup for all actions
    charset 'UTF-8'

    # setup for `rss` action
    setup :rss do
        content_type '.rss'
    end

    def latest
        # ...
    end

    def rss
        # ...
    end
end
```
<commit_msg>Update Intro.md<commit_after>## Actions

The cornerstone of any Espresso app.

Namely, actions are the workhorses that creates the routes to be served by app, as well as running our code.

If we need user to see "Hello World!" when he visits "/hello" address in the browser, we simply do like this:

```ruby
def hello
    "Hello World!"
end
```

It is really straightforward to define actions in Espresso cause they are usual Ruby methods.


**[ [contents &uarr;](https://github.com/slivu/espresso#tutorial) ]**


## Controllers


A controller is meant to organize and setup actions.

The basic setup is base URL. It is defaulted to the controller's underscored name and are used by all actions.

Other setups are action-specific and can be set for N or for all actions.<br/>
To define a setup for all actions, simply call appropriate method at controller's class level.<br/>
To setup specific actions, call appropriate methods inside `setup` proc that will accept action names as arguments.<br/>
Action names can also be given as regular expressions.

**Example:** - Creating a controller that will serve "/pages/latest" and "/pages/rss" URLs

```ruby
class Pages < E

    # setup for all actions
    charset 'UTF-8'

    # setup for `rss` action
    setup :rss do
        content_type '.rss'
    end

    def latest
        # ...
    end

    def rss
        # ...
    end
end
```

{'fraction_non_alphanumeric': 0.08065099457504521, 'fraction_numerical': 0.0007233273056057866, 'mean_word_length': 3.2423312883435584, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2413033', 'n_tokens_mistral': 796, 'n_tokens_neox': 751, 'n_words': 391}