Open BuddhiLW opened 2 years ago
You should just be able to serve the PDF as a resource from the public folder.
(defroutes routes
(GET "/" [] (redirect
(let [config (resolve-config)]
(path (:blog-prefix config)
(when (= (:clean-urls config) :dirty)
"index.html")))))
(GET "/cv1" [] (ring.util.response/file-response
(path
"public/pdf/cv-2022-11-03.pdf")))
(GET "/cv2" [] (ring.util.response/file-response
(path
"pdf/cv-2022-11-03.pdf")))
(GET "/cv3" [] (ring.util.response/file-response
(path "cv-2022-11-03.pdf")))
$ tree public/pdf/
public/pdf/
├── cv-2021-08-11.pdf
└── cv-2022-11-03.pdf
0 directories, 2 files
This doesn't work. None of the three end-points. I don't know what to try further.
Oh, yeah, if I run lein serve
, it works on localhost:3000/v1
and v3
.
But, not on the deployed website.
The problem there is that you won't have a server running once you build the site. You'd have to link to the PDF file from the page relative to your public folder.
I see.
Could you give me an example, or a direction, of how I may achieve that? I have no idea.
Thanks in advance.
I want to create a router for/cv1 and serve a pdf.
Locally, it works just fine. That is,
curl
will work. And, the page renders a pdf on the browser.Locally:
But, in my website, it gives 404, www.buddhilw.com/cv1.
In the
server.clj
, I defined the routercv1
, as so:What could I do to accomplish the file-serving?
What I have tried
(path "<path>.pdf") and dropping the
(let [config (resolve-config)] ...)` stuffNone worked.