kemal/docs/getting_started.md

86 lines
1.3 KiB
Markdown
Raw Normal View History

2015-12-04 11:26:15 +00:00
# Kemal Tutorial
2015-12-05 11:52:07 +00:00
## 1. Install Crystal
2015-12-04 11:26:15 +00:00
```
brew update
brew install crystal-lang
```
2015-12-05 11:52:07 +00:00
## 2. Installing Kemal
2015-12-04 11:26:15 +00:00
You should create your application first:
```
2015-12-07 20:03:35 +00:00
crystal init app your_app
cd your_app
2015-12-04 11:26:15 +00:00
```
Then add *kemal* to the `shard.yml` file as a dependency.
2015-12-04 11:36:06 +00:00
```yml
2015-12-04 11:26:15 +00:00
dependencies:
kemal:
github: sdogruyol/kemal
branch: master
```
You should run `shards` to get dependencies:
```
shards install
```
2015-12-05 11:52:07 +00:00
It will output something like that:
```
$ shards install
Updating https://github.com/sdogruyol/kemal.git
Installing kemal (master)
```
## 3. Include Kemal into your project
2015-12-04 11:26:15 +00:00
2015-12-07 20:03:35 +00:00
Open `your_app/src/your_app.cr` and require `kemal` to use Kemal.
2015-12-04 11:26:15 +00:00
2015-12-04 11:36:06 +00:00
```ruby
2015-12-04 11:26:15 +00:00
require 'kemal'
```
2015-12-05 11:52:07 +00:00
## 4. Hack your project
2015-12-04 11:26:15 +00:00
Do some awesome stuff with awesome Kemal.
2015-12-04 11:36:06 +00:00
```ruby
2015-12-04 11:26:15 +00:00
get "/" do
"Hello World!"
end
```
2015-12-05 11:52:07 +00:00
All the code should look like this:
```ruby
require "kemal"
2015-12-07 20:03:35 +00:00
get "/" do
"Hello World!"
2015-12-05 11:52:07 +00:00
end
```
## 5. Run your awesome web project.
2015-12-04 11:26:15 +00:00
```
2015-12-07 20:03:35 +00:00
crystal build --release src/your_app.cr
./your_app
2015-12-04 11:26:15 +00:00
```
2015-12-05 11:52:07 +00:00
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)
```
2015-12-04 11:26:15 +00:00
Now you can be happy with your new, very fast, readable web project.