Skip to content

Instantly share code, notes, and snippets.

```
defmodule AppWeb.PageLive do
@moduledoc """
This is the web interface for the testbed application.
This is where the HTML is rendered and CSS is applied.
The core of this apps code resides here.
1. Code that listens and respond to interactive user events is written here.
2. Code here moves data to and from the database.

How to build a JSON API with Elixir & Phoenix

Welcome! In this guide we'll go step by step to build an API with Elixir and the Phoenix Framework.

Note, i wrote this around 2017/18 so things might have changed. Also it's incomplete. Hopefully still useful. Yadayada.

Here's the plan:

  • Install Elixir
  • Create a new Phoenix project
defmodule App do
use GenServer
def start_link([]) do
GenServer.start_link(__MODULE__, [])
end
def init(state) do
{:ok, state}
end

Basic transition

HTML

<div></div>

CSS

# Routify & Svelte

Sever Side s Client Side Rendering

Server side

Client side

Svelte Notes

Built in web server

Go to directory of project

php -S localhost:8000

Parts of a Class

The class name

The attributes (properties of the class). The properties have this format:

-name: string
-age: int
-id: -int

Parts of a Class

The class name

The attributes (properties of the class). The properties have this format:

-name: string
-age: int
-id: -int