shard-kemal/samples/hello_world.cr

14 lines
360 B
Crystal
Raw Normal View History

2015-10-23 18:50:19 +00:00
require "kemal"
2014-06-11 23:41:02 +00:00
2015-10-23 19:25:46 +00:00
# Set root. If not specified the default content_type is 'text'
2014-06-11 23:41:02 +00:00
get "/" do
2015-10-23 19:25:46 +00:00
"Hello Kemal!"
end
# You can easily access the environment and set content_type like 'application/json'.
# Look how easy to build a JSON serving API.
get "/user.json" do |env|
env.response.content_type = "application/json"
{name: "Serdar", age: 27}.to_json
2014-06-11 23:41:02 +00:00
end