{"id":28816851,"url":"https://github.com/babashka/http-server","last_synced_at":"2025-10-26T04:11:01.030Z","repository":{"id":39513962,"uuid":"442217211","full_name":"babashka/http-server","owner":"babashka","description":"Serve static assets","archived":false,"fork":false,"pushed_at":"2025-04-14T15:00:17.000Z","size":40,"stargazers_count":79,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-07T23:50:37.755Z","etag":null,"topics":["babashka","clojure"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babashka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-27T16:46:23.000Z","updated_at":"2025-05-28T21:38:10.000Z","dependencies_parsed_at":"2023-11-26T00:19:18.958Z","dependency_job_id":"7d795101-5e7a-43a0-b3fd-3845b3b4ddce","html_url":"https://github.com/babashka/http-server","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/babashka/http-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fhttp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fhttp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fhttp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fhttp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babashka","download_url":"https://codeload.github.com/babashka/http-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fhttp-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260595742,"owners_count":23033789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babashka","clojure"],"created_at":"2025-06-18T17:07:23.544Z","updated_at":"2025-10-26T04:11:01.011Z","avatar_url":"https://github.com/babashka.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# http-server\n\n[![Clojars Project](https://img.shields.io/clojars/v/org.babashka/http-server.svg)](https://clojars.org/org.babashka/http-server)\n\nServe static assets.\n\nWorks in [clojure JVM](#clojure) and [babashka](#babashka).\n\n## [API](API.md)\n\n## Clojure\n\nTo your `deps.edn` add an alias:\n\n``` clojure\n:serve {:deps {org.babashka/http-server {:mvn/version \"0.1.14\"}}\n        :main-opts [\"-m\" \"babashka.http-server\"]\n        :exec-fn babashka.http-server/exec}\n```\n\nThen run from the command line:\n\n``` clojure\nclj -M:serve :port 1339 :dir \".\" :headers '{\"Cross-Origin-Opener-Policy\" \"same-origin\"}'\n```\n\nor:\n\n``` clojure\nclj -X:serve :port 1339 :dir '\".\"' :headers '{\"Cross-Origin-Opener-Policy\" \"same-origin\"}'\n```\n\nOr install as a tool:\n\n``` clojure\n$ clj -Ttools install io.github.babashka/http-server '{:git/tag \"v0.1.14\"}' :as serve\n$ clj -Tserve exec\n```\n\n## Babashka\n\nIn a script, e.g. `/usr/local/bin/http-server`:\n\n``` clojure\n#!/usr/bin/env bb\n\n(require '[babashka.deps :as deps])\n(deps/add-deps\n '{:deps {org.babashka/http-server {:mvn/version \"0.1.14\"}}})\n\n(require '[babashka.http-server :as http-server])\n\n(apply http-server/-main *command-line-args*)\n```\n\nThen invoke using:\n\n``` clojure\n$ http-server --port 8888 --dir resources/public --headers '{\"Cross-Origin-Opener-Policy\" \"same-origin\"}'\n```\n\nIn `bb.edn` [tasks](https://book.babashka.org/#tasks):\n\n``` clojure\n{:deps {org.babashka/http-server {:mvn/version \"0.1.14\"}\n        org.babashka/cli {:mvn/version \"0.2.23\"}}\n :tasks\n {:requires ([babashka.cli :as cli])\n  :init (def cli-opts (cli/parse-opts *command-line-args* {:coerce {:port :int :headers :edn}}))\n\n  serve {:doc \"Serve static assets\"\n         :requires ([babashka.http-server :as server])\n         :task (server/exec (merge {:port 1337\n                                    :dir \".\"}\n                                   cli-opts))}\n\n  prn {:task (clojure \"-X clojure.core/prn\" cli-opts)}\n\n  -dev {:depends [serve prn]}\n\n  dev {:task (run '-dev {:parallel true})}}}\n```\n\n``` clojure\n$ bb dev --port 1338\nServing assets at http://localhost:1338\n{:port 1338}\n```\n\n## Credits\n\nThanks to [Jakub Holy](https://github.com/holyjak) who made this\n[gist](https://gist.github.com/holyjak/36c6284c047ffb7573e8a34399de27d8) which\nwas in turn based on\n[this](https://github.com/babashka/babashka/blob/master/examples/image-viewer.clj)\nbabashka example. I used several variations of this in my own projects, which\neventually became this repo.\n\n## License\n\nCopyright © 2022 Michiel Borkent\n\nDistributed under the MIT License. See LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Fhttp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabashka%2Fhttp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Fhttp-server/lists"}