{"id":22001458,"url":"https://github.com/alshdavid/http-server-rs","last_synced_at":"2025-03-23T05:27:22.757Z","repository":{"id":248797236,"uuid":"829813325","full_name":"alshdavid/http-server-rs","owner":"alshdavid","description":"Static HTTP Server For Local Development","archived":false,"fork":false,"pushed_at":"2025-03-05T15:56:53.000Z","size":128,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T16:41:37.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Handlebars","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/alshdavid.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-07-17T03:44:39.000Z","updated_at":"2025-03-05T15:56:56.000Z","dependencies_parsed_at":"2025-01-08T04:19:05.517Z","dependency_job_id":"d9cf5013-a158-45c4-8721-9febc43e7b87","html_url":"https://github.com/alshdavid/http-server-rs","commit_stats":null,"previous_names":["alshdavid/http-server-rs"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshdavid%2Fhttp-server-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshdavid%2Fhttp-server-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshdavid%2Fhttp-server-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshdavid%2Fhttp-server-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alshdavid","download_url":"https://codeload.github.com/alshdavid/http-server-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245061384,"owners_count":20554563,"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":[],"created_at":"2024-11-29T23:13:55.012Z","updated_at":"2025-03-23T05:27:22.748Z","avatar_url":"https://github.com/alshdavid.png","language":"Handlebars","funding_links":[],"categories":[],"sub_categories":[],"readme":"# http-server: a simple static HTTP server 🚀🦀\n\nRewrite of the popular npm package [http-server](https://github.com/http-party/http-server/tree/master) in Rust with some extras included.\n\n`http-server` is a simple, zero-configuration command-line static HTTP server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development and learning.\n\nhttps://github.com/user-attachments/assets/7b6bbee0-3428-4c9f-80a6-2804ddac6e01\n\n## Usage\n\n```bash\n# Use default configuration\nhttp-server\n\n# Arguments\n# Enable CORS, reroute requests to index.html and automatically compress to brotli \nhttp-server --cors --spa -Z ./public\n\n# Custom Headers\nhttp-server -H X-Custom-Header:some-value\n```\n\n```\nUsage: http-server [OPTIONS] [SERVE_DIR]\n\nArguments:\n  [SERVE_DIR]  Target directory to serve [default: ./dist]\n\nOptions:\n  -a, --address \u003cADDRESS\u003e        [default: 0.0.0.0]\n  -p, --port \u003cPORT\u003e              [default: 8080]\n      --spa                      Redirect requests to /index.html for Single Page Applications\n  -c, --cache-time \u003cCACHE_TIME\u003e  Cache control time [default: 0]\n  -Z, --compress                 Compress responses (JIT)\n  -H, --header \u003cHEADERS\u003e         Custom headers (Format \"key:value\")\n      --cors                     Enable CORS header\n  -S, --shared-array-buffer      Enable headers for SharedArrayBuffer\n  -Q, --quiet                    Don't print any logs to terminal\n  -w, --watch                    Watch folder for changes and trigger a browser reload\n      --watch-dir \u003cWATCH_DIR\u003e    Watch for changes [default: SERVE_DIR]\n      --no-watch-inject          Don't automatically inject watch listener into html\n  -h, --help                     Print help\n```\n\n## Watch Mode\n\n`http-server` under `--watch` mode can watch the served directory for changes and emit an event to the client notifying of a change. By default the server will intercept html files and inject a JavaScript script which subscribes to change events and triggers a page reload.\n\n```bash\nhttp-server --watch ./dist\n```\n\nTo customize the reload functionality, disable the auto-inject script, manually subscribe to change events and trigger the desired functionality.\n\n```bash\nhttp-server --watch --no-watch-inject ./dist\n```\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript\u003e\n      new EventSource(\"/.http-server-rs/reload\")\n        .onmessage = () =\u003e window.location.reload();\n    \u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cscript src=\"./app.js\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Installation\n\n### MacOS \u0026 Linux\n\nDownload the binary from the [latest GitHub release](https://github.com/alshdavid/http-server-rs/releases/latest) and add it to your `PATH`\n\n```shell\n# Linux AMD64\ncurl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-linux-amd64.tar.gz | tar -xvzf - -C $HOME/.local/bin\n\n# Linux ARM64\ncurl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-linux-arm64.tar.gz | tar -xvzf - -C $HOME/.local/bin\n\n# MacOS ARM64 (Apple Silicon)\ncurl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-macos-arm64.tar.gz | tar -xvzf - -C $HOME/.local/bin \n\n# MacOS AMD64 (Intel)\ncurl -L --url https://github.com/alshdavid/http-server-rs/releases/latest/download/http-server-macos-amd64.tar.gz | tar -xvzf - -C $HOME/.local/bin\n\n# Add to PATH if not already there:\necho \"\\nexport \\PATH=\\$PATH:\\$HOME/.local/bin\\n\" \u003e\u003e $HOME/.zshrc\necho \"\\nexport \\PATH=\\$PATH:\\$HOME/.local/bin\\n\" \u003e\u003e $HOME/.bashrc\n```\n\n### Windows\n\nDownload the binary from the [latest GitHub release](https://github.com/alshdavid/http-server-rs/releases/latest) and add it to your `PATH`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falshdavid%2Fhttp-server-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falshdavid%2Fhttp-server-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falshdavid%2Fhttp-server-rs/lists"}