<commit_before># Phoenix
> Realtime Elixir Web Framework

## Goals
- First class websockets
- Ring distribution

```elixir
defmodule Router do
  use Phoenix.Router, port: 4000

  get "pages/:page", PagesController, :show, as: :page
  get "files/*path", FilesController, :show
  get "profiles/user-:id", UsersController, :show
  resources "users", UsersController
end

defmodule PagesController do
  use Phoenix.Controller

  def show(conn) do
    text conn, "Hello! #{conn.params["page"]}"
  end
end

defmodule UsersController do
  use Phoenix.Controller

  def show(conn) do
    text conn, "Showing user #{conn.params["id"]}"
  end

  def index(conn) do
    html conn, """
    <html>
      <body>
        <h1>Users</h1>
      </body>
    </html>
    """
  end
end
```

## Starting the application

```bash
$ mix run -e 'Router.start' --no-halt mix.exs
```<commit_msg>Add redirect/named route example<commit_after># Phoenix
> Realtime Elixir Web Framework

## Goals
- First class websockets
- Ring distribution

```elixir
defmodule Router do
  use Phoenix.Router, port: 4000

  get "pages/:page", PagesController, :show, as: :page
  get "files/*path", FilesController, :show
  get "profiles/user-:id", UsersController, :show
  resources "users", UsersController
end

defmodule PagesController do
  use Phoenix.Controller

  def show(conn) do
    if conn.params["id"] in ["1", "2", "3"] do
      redirect conn, Router.page_path(page: conn.params["id"])
    else
      text conn, "Showing user #{conn.params["id"]}"
    end
  end

end

defmodule UsersController do
  use Phoenix.Controller

  def show(conn) do
    text conn, "Showing user #{conn.params["id"]}"
  end

  def index(conn) do
    html conn, """
    <html>
      <body>
        <h1>Users</h1>
      </body>
    </html>
    """
  end
end
```

## Starting the application

```bash
$ mix run -e 'Router.start' --no-halt mix.exs
```
{'fraction_non_alphanumeric': 0.13605082053996823, 'fraction_numerical': 0.007940709370037057, 'mean_word_length': 3.324942791762014, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, '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': '1904469', 'n_tokens_mistral': 652, 'n_tokens_neox': 621, 'n_words': 193}