Skip to content

Instantly share code, notes, and snippets.

@dannysmith
Created December 10, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannysmith/a5a4c213a44d98b40bf43d23dacd9b15 to your computer and use it in GitHub Desktop.
Save dannysmith/a5a4c213a44d98b40bf43d23dacd9b15 to your computer and use it in GitHub Desktop.
Example Crystal Project
# Crystal program
puts "What's your name?"
print "-> "
name = gets.to_s.chomp
puts "Your name is #{name.capitalize}"
puts "-------------" + ("-" * name.size)
# A very basic HTTP server
require "http/server"
server = HTTP::Server.new(8080) do |context|
context.response.content_type = "text/plain"
context.response.print "Hello #{name}, got #{context.request.path}!"
end
puts "Listening on http://127.0.0.1:8080"
server.listen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment