I'm trying to start a simple server in Julia. (Julia 1.7, HTTP v0.9.16, Windows 10).
By copying the snippet in the HTTP docs, I've written
using HTTP
using Sockets
HTTP.serve(Sockets.localhost, 8000) do request::HTTP.Request
@show HTTP.header(request, "Content-Type")
@show HTTP.payload(request)
return HTTP.Response("Helllllo")
end
in a julia terminal.
When i navigate to http://localhost:8000/ in Chrome, it Does show a page with the word "Helllllo".
But, when i try to send GET requests to it, it doesn't answer. Things I tried:
Opening a new julia terminal and writing
using HTTP r = HTTP.request("GET", "https://127.0.0.1:8000");
What happens is that this command hangs, instead of producing a r.
Going in Chrome console and writing
fetch("https://127.0.0.1:8000") .then(res => res.json()) .then(console.log)
Again, no answer.
What am I doing wrong?
Thanks!