I have a very simple HTTP server that I want to run
using Pkg
Pkg.add("HTTP")
using HTTP
# if false
ENV["PORT"] = "8080"
# end
print(ENV["PORT"])
const PORT = parse(Int, ENV["PORT"])
using HTTP
# HTTP.listen! and HTTP.serve! are the non-blocking versions of HTTP.listen/HTTP.serve
server = HTTP.serve!(PORT) do request::HTTP.Request
@show request
@show request.method
@show HTTP.header(request, "Content-Type")
@show request.body
try
return HTTP.Response("Hello")
catch e
return HTTP.Response(400, "Error: $e")
end
end
#close(server)
So I try to trigger it using julia server.jl
from bash and it seems to close instantly.
I am very new to this web things, what do I need to do to keep this server running so I can test it by sending request to it?