HTTP server that returns JSON #1955
mvolkmann
started this conversation in
Show and tell
Replies: 1 comment
-
I'm very happy that About the favicon.ico handler: right now you can define a handler for every path that is not any of the others, which can be used to generate custom 404 pages. Usually, webapps should do that. However, if you don't define anything it shouldn't return an error either because the HTTP server should send a 404 anyway... So maybe that's a bug. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been learning about the
http/httpl_server
library. I wanted to see if I could implement an HTTP server that takes somewhat random queries through an HTTP query parameter and provides JSON responses.Step 1 was coming up with a reasonable JSON representation for any term. See
lib/json.pl
and the tests inlib/json.plt
in the GitHub repo linked below.Step 2 was figuring out how to take a query parameter like
q=grandfather,X,Y
, translate that to running the querygrandfather(X, Y)
, generate JSON from the solutions, and return it in an HTTP response.I finally got it all working! See https://github.com/mvolkmann/prolog-examples/blob/main/http_server_scryer.pl.
I'm definitely open to feedback if there's anything I could have done better.
Beta Was this translation helpful? Give feedback.
All reactions