kemal/docs/tutorial.md
2015-12-05 13:52:07 +02:00

1.4 KiB

Kemal Tutorial

1. Install Crystal

brew update
brew install crystal-lang

2. Installing Kemal

You should create your application first:

crystal init app awesome_web_project
cd awesome_web_project

Then add kemal to the shard.yml file as a dependency.

dependencies:
  kemal:
    github: sdogruyol/kemal
    branch: master

You should run shards to get dependencies:

shards install

It will output something like that:

$ shards install
Updating https://github.com/sdogruyol/kemal.git
Installing kemal (master)

3. Include Kemal into your project

Open awesome_web_project/src/awesome_web_project.cr and require kemal to use Kemal.

require 'kemal'

4. Hack your project

Do some awesome stuff with awesome Kemal.

get "/" do
  "Hello World!"
end

All the code should look like this:

require "./crystal_test/*"
require "kemal"

module AwesomeWebProject
  get "/" do
    "Hello World!"
  end
end

5. Run your awesome web project.

crystal build --release src/awesome_web_project.cr
./awesome_web_project

You should see some logs like these:

[development] Kemal is ready to lead at http://0.0.0.0:3000
2015-12-01 13:47:48 +0200 | 200 | GET / - (666µs)
2015-12-05 13:47:48 +0200 | 404 | GET /favicon.ico - (14µs)

Now you can be happy with your new, very fast, readable web project.