calling from other languages #1931
-
Is it possible to evaluate a Prolog goal from another programming language using Scryer for the evaluation? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
There is ongoing work for making Scryer available as a library, see especially #225 and #1880. Regarding HTTP: You can easily create an HTTP server with Scryer Prolog, using https://www.scryer.pl/http/http_server.html Such a server can receive queries and respond with answers, I think such a setup and separation is easiest to debug, and I would recommend it if possible. |
Beta Was this translation helpful? Give feedback.
-
Here is a basic example of using the http/http_server library. When I run this I get "Warning: overwriting http_listen/2" and the server doesn't work. Am I using the library incorrectly? :- use_module(library(http/http_server)).
text_handler(_, Response) :-
http_status_code(Response, 200),
http_body(Response, text("Welcome to Scryer Prolog!")).
http_listen(8081, [
get(echo, text_handler)
]). |
Beta Was this translation helpful? Give feedback.
-
@david-sitsky When I start the HTTP server using the approach you suggested, pressing ctrl-c or ctrl-d in the top level does not stop it. The only way I've found to stop it is to use the |
Beta Was this translation helpful? Give feedback.
I think what you want is this:
Then from the prompt, do the following:
Sure enough, visiting http://localhost:8081/echo works and I see the "Welcome to Scryer Prolog!" text. However the prompt shows an error soon after. The browser (chrome) seem to request favicon.ico which presumably also needs a handler?