404 error
parent
46008c7feb
commit
b6b52c632a
|
@ -2,7 +2,6 @@ require "http/server"
|
|||
require "option_parser"
|
||||
|
||||
VERSION = 0.1
|
||||
|
||||
port = 3000
|
||||
|
||||
OptionParser.parse do |parser|
|
||||
|
@ -23,10 +22,14 @@ OptionParser.parse do |parser|
|
|||
end
|
||||
|
||||
server = HTTP::Server.new do |context|
|
||||
pp context.request
|
||||
if context.request.method != "POST" || context.request.path != "/"
|
||||
context.response.status = HTTP::Status::NOT_FOUND
|
||||
else
|
||||
context.response.content_type = "text/plain"
|
||||
context.response.print "Hello world! The time is #{Time.local}"
|
||||
end
|
||||
end
|
||||
|
||||
address = server.bind_tcp port
|
||||
puts "Listening on http://#{address}"
|
||||
server.listen
|
||||
|
|
Loading…
Reference in New Issue