first commit
commit
46008c7feb
|
@ -0,0 +1,19 @@
|
||||||
|
name: webhooksd
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
# authors:
|
||||||
|
# - name <email@example.com>
|
||||||
|
|
||||||
|
# description: |
|
||||||
|
# Short description of webhooksd
|
||||||
|
|
||||||
|
# dependencies:
|
||||||
|
# pg:
|
||||||
|
# github: will/crystal-pg
|
||||||
|
# version: "~> 0.5"
|
||||||
|
|
||||||
|
# development_dependencies:
|
||||||
|
# webmock:
|
||||||
|
# github: manastech/webmock.cr
|
||||||
|
|
||||||
|
# license: MIT
|
|
@ -0,0 +1,32 @@
|
||||||
|
require "http/server"
|
||||||
|
require "option_parser"
|
||||||
|
|
||||||
|
VERSION = 0.1
|
||||||
|
|
||||||
|
port = 3000
|
||||||
|
|
||||||
|
OptionParser.parse do |parser|
|
||||||
|
parser.banner = "usage: webhooksd <scriptfile> [option]"
|
||||||
|
parser.on "-v", "--version", "Show version" do
|
||||||
|
puts "version #{VERSION}"
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
parser.on "-h", "--help", "Show help" do
|
||||||
|
puts parser
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
parser.on "-p PORT", "--port=PORT", "Port to listen for connections. Default: 3000" do |p|
|
||||||
|
port = p.to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
server = HTTP::Server.new do |context|
|
||||||
|
context.response.content_type = "text/plain"
|
||||||
|
context.response.print "Hello world! The time is #{Time.local}"
|
||||||
|
end
|
||||||
|
|
||||||
|
address = server.bind_tcp port
|
||||||
|
puts "Listening on http://#{address}"
|
||||||
|
server.listen
|
Loading…
Reference in New Issue