Reputation: 49
we have a Julia language calculation engine we want to trigger on command from a HTML webpage.
How can I connect from this application to a Julia instance. Is it possible to connect to Julia via a REST service?
Upvotes: 3
Views: 412
Reputation: 31342
You just need to have Julia listening on a port for incoming requests and have it respond accordingly. You can use an HTTP package (like HTTP.jl) to easily set up a REST endpoint:
import HTTP
using Sockets
compute(req::HTTP.Request) = HTTP.Response(200, "hello world")
const SERVER = HTTP.Router()
HTTP.@register(SERVER, "GET", "/test", compute)
HTTP.serve(SERVER, ip"127.0.0.1", 12345)
Now accessing http://127.0.0.1:12345/test
should show you a page with the string hello world on it.
There are many frameworks that build atop this basic paradigm.
Upvotes: 7