-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Labels
Description
Web developers need a way to automatically update server behavior with changes to local development files. This is unobvious for those unfamiliar with HTTP.jl, Revise.jl, and their interaction. Below is a proposed example that works, at least for local development.
# hello.jl -- an example showing how Revise.jl works with HTTP.jl
# julia> using Revise; includet("hello.jl"); serve();
using HTTP
using Sockets
homepage(req::HTTP.Request) =
HTTP.Response(200, "<html><body>Hello World!</body></html>")
const ROUTER = HTTP.Router()
HTTP.@register(ROUTER, "GET", "/", homepage)
serve() = HTTP.listen(request -> begin
Revise.revise()
Base.invokelatest(HTTP.handle, ROUTER, request)
end, Sockets.localhost, 8080, verbose=true)
c42f, rikhuijzer and tjpalanca