404 error

master
Izimic 2020-11-26 15:27:17 +01:00
parent 46008c7feb
commit b6b52c632a
1 changed files with 7 additions and 4 deletions

View File

@ -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