aboutsummaryrefslogtreecommitdiff
path: root/src/indrajith-dev-crystal.cr
blob: ca600f152833cb4ca30cd1fa62ace1ca8bf91dc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require "kemal"

module Indrajith::Dev::Crystal
  VERSION = "0.1.0"

  macro page_renderer(filename, title)
    page_title = {{title}}
    render "src/views/#{{{filename}}}.ecr", "src/views/layout.ecr"
  end

  get "/" do |context|
    context.response.content_type = "text/html"
    page_renderer "home", "Home"
  end

  get "/about" do |context|
    context.response.content_type = "text/html"
    page_renderer "about", "About "
  end

  get "/timeline" do |context|
    context.response.content_type = "text/html"
    page_renderer "timeline", "Timeline"
  end

  get "/contact" do |context|
    context.response.content_type = "text/html"
    page_renderer "contact", "Contact"
  end

  error 404 do |context|
    context.response.content_type = "text/html"
    page_renderer "404", "The VOID"
  end

  Kemal.run
end