This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-20
Channels
- # bangalore-clj (1)
- # beginners (145)
- # boot (8)
- # braid-chat (2)
- # capetown (2)
- # cider (27)
- # cljs-dev (232)
- # cljsrn (30)
- # clojure (223)
- # clojure-boston (1)
- # clojure-dusseldorf (2)
- # clojure-greece (1)
- # clojure-italy (21)
- # clojure-russia (16)
- # clojure-sanfrancisco (13)
- # clojure-spec (33)
- # clojure-uk (56)
- # clojurescript (165)
- # core-async (16)
- # core-logic (5)
- # cursive (14)
- # data-science (2)
- # datavis (2)
- # datomic (49)
- # duct (15)
- # editors (5)
- # emacs (6)
- # fulcro (11)
- # graphql (11)
- # hoplon (8)
- # jobs (4)
- # jobs-discuss (82)
- # jobs-rus (7)
- # leiningen (4)
- # luminus (5)
- # off-topic (90)
- # om (7)
- # om-next (1)
- # parinfer (67)
- # pedestal (34)
- # portkey (46)
- # re-frame (12)
- # reagent (4)
- # reitit (3)
- # remote-jobs (1)
- # ring-swagger (8)
- # shadow-cljs (13)
- # spacemacs (18)
- # specter (6)
- # sql (5)
- # tools-deps (4)
- # unrepl (40)
- # yada (26)
Hi guys, looking for a bit of help with this piece of code
(defn resource-routes []
(yada/listener
[""
[["/" (yada/handler (file "app.html"))]
["/" (yada/handler (resource "/resources/"))]]]
{:port 5000}))
I’m building a very simple website (a single page to be precise) but I am having trouble getting yada to serve up the files in resources/public/… directory, I’ve tired a few different approaches to the above but thats were I currently left it off; Working with the webpage directly for the mean time.
Also on top of that, what is the correct way to shutdown the server. As per the documentation I call ((:close (resource-routes)))
but it returns CompilerException java.net.BindException: Address already in use
which means I cannot refresh changes without forcing closed the REPL and occasionally having to open up Activity Monitor and force close form there. What I am asking what is the best/right way to close/restart the server.I think that should be (resource "")
or maybe it should be the yada classpath resource from the namespace of the same name
I tried the (new-classpath-resource)
and it didn’t work for me either, I had looked at an old response for more or less than same issue I am having and it suggested the classpath resource though that didn’t work for me.
using (new-classpath-resource)
produces, in the browser, Failed to load resource: the server responded with a status of 404 (Not Found)
Oh, I remember how it works, try ""
instead of "/"
for the bidi route for your classpath resource
Still getting 404
, it’s odd why I can’t get it to work
@severed-infinity what does your project.clj look like? (presuming you're using lein)
specifically, do you have anything in there specifying resource directories, or is it just the lein default
:description "FIXME: write description"
:url ""
:license {:name "Eclipse Public License"
:url ""}
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.946"]
[hiccup "1.0.5"]
[aleph "0.4.4"]
[bidi "2.1.3"]
[yada "1.2.11"]
[reagent "0.8.0-alpha2"]
[re-frame "0.10.5"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.15"]]
:main yugiohcardeffect.clj.core
:target-path "target/%s"
:cljsbuild {:builds [{; The path to the top-level ClojureScript source directory:
:source-paths ["src/"]
:id "main"
:figwheel true
; The standard ClojureScript compiler options:
; (See the ClojureScript compiler documentation for details.)
:compiler {:main yugiohcardeffect.cljs.builder
:output-to "resources/public/js/main.js" ; default: target/cljsbuild-main.js
:optimizations :none
:pretty-print true}}]}
:figwheel {:ring-handler yugiohcardeffect.clj.core/start}
:profiles {:uberjar {:aot :all}})
^^^ Agreed. if not add :resource-paths ["resources"]
to your project.clj; I can't remember off the top of my head if lein adds that by default like it does src
for :source-paths
it doesn’t as thats the default except cljsbuild
Added the :resource-paths
and tired (resource "public/js/main.js")
, I don’t get a 404 but clicking on the file in the browser opens a about:blank
page and empty file in console
@severed-infinity I meant that you should run that code in the repl :)
it returns the correct file path
Okay, good. Just checking. Switch back to classpath resource in the routes, that's definitely the way forward.
on chrome I get GET
while on safari I get Failed to load resource: the server responded with a status of 404 (Not Found)
but beyond that I’ve not moved forwards nor backwards since yesterday just staying at this impasse.
I’ve ranged from having very specific file paths to no file paths, from using file
, resource
, new-classpath-resource
all of which produce slightly different variations of each other