Commit unstaged changes

This commit is contained in:
heyarne 2022-02-19 19:35:51 +01:00
commit e730a5cc5e
2 changed files with 12 additions and 11 deletions

View file

@ -8,7 +8,7 @@ The project is built via [shadow-cljs](https://shadow-cljs.github.io/docs/UsersG
You can run a dev build like so: You can run a dev build like so:
``` sh ``` sh
npx shadow-cljs server :app clojure -A:cljs -m shadow.cljs.devtools.cli server app
``` ```
This starts a web server at localhost:8080 and also starts an nRPL server that you can connect to in your editor This starts a web server at localhost:8080 and also starts an nRPL server that you can connect to in your editor
@ -16,13 +16,13 @@ This starts a web server at localhost:8080 and also starts an nRPL server that y
Similarly, a production-optimized app can be generated via Similarly, a production-optimized app can be generated via
``` sh ``` sh
npx shadow-cljs release :app clojure -A:cljs -m shadow.cljs.devtools.cli release app
``` ```
If you want to get detailed info about bundle size, try: If you want to get detailed info about bundle size, try:
``` sh ``` sh
npx shadow-cljs run shadow.cljs.build-report :app report.html clojure -A:cljs -m shadow.cljs.build-report app report.html
``` ```
The server component has to be started separately. The server component has to be started separately.

View file

@ -18,23 +18,24 @@
(io/copy (-> file :tempfile) (io/file (str filename "." img-ext))) (io/copy (-> file :tempfile) (io/file (str filename "." img-ext)))
(spit (str filename ".json") predictions))) (spit (str filename ".json") predictions)))
(def app (defn upload-handler [req]
(ring/ring-handler
(ring/router
[["/upload"
;; TODO: Verify params ;; TODO: Verify params
{:post (fn [req]
(let [{:keys [snapshot predictions]} (-> req :params)] (let [{:keys [snapshot predictions]} (-> req :params)]
(upload! snapshot predictions) (upload! snapshot predictions)
{:status 201 {:status 201
:body "Thanks :)"}))}] :body "Thanks :)"}))
(def app
(ring/ring-handler
(ring/router
[["/upload" {:post upload-handler}]
["/*" (ring/create-resource-handler)]] ["/*" (ring/create-resource-handler)]]
{:conflicts (constantly nil)}))) {:conflicts (constantly nil)})))
(defonce server (atom nil)) (defonce server (atom nil))
(defn stop-server [] (defn stop-server []
(when-not (nil? @server) (when @server
(println "Stopping server…") (println "Stopping server…")
(@server :timeout 100) (@server :timeout 100)
(reset! server nil))) (reset! server nil)))