{"id":20822157,"url":"https://github.com/internetarchive/file_server_plus","last_synced_at":"2026-04-25T09:38:02.194Z","repository":{"id":59030116,"uuid":"535102654","full_name":"internetarchive/file_server_plus","owner":"internetarchive","description":"`deno` static file webserver, clone of `file_server.ts`, PLUS an additional final \"404 handler\" to run arbitrary JS/TS","archived":false,"fork":false,"pushed_at":"2022-09-12T02:02:33.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":14,"default_branch":"main","last_synced_at":"2024-04-14T13:06:34.714Z","etag":null,"topics":["deno","fileserver","httpd","static-files","webserver"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/internetarchive.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}},"created_at":"2022-09-10T19:46:39.000Z","updated_at":"2022-10-13T07:57:13.000Z","dependencies_parsed_at":"2022-09-10T23:55:15.658Z","dependency_job_id":null,"html_url":"https://github.com/internetarchive/file_server_plus","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Ffile_server_plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Ffile_server_plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Ffile_server_plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Ffile_server_plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/internetarchive","download_url":"https://codeload.github.com/internetarchive/file_server_plus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243169016,"owners_count":20247456,"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":["deno","fileserver","httpd","static-files","webserver"],"created_at":"2024-11-17T22:14:06.378Z","updated_at":"2025-12-24T09:26:39.831Z","avatar_url":"https://github.com/internetarchive.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# file_server_plus\nThis is a `deno` static file webserver, copied from: [file_server.ts](https://github.com/denoland/deno_std/blob/main/http/file_server.ts), with an additional final \"404 handler\" ability to run arbitrary JS/TS, path match routes for dynamically running JS/TS, etc.\n\nThis can be useful for Single Page Application type setups (and more) for when you want an URL path to run certain code.\n\nThe script should be relative from the static files directory.\n\nFor example, if you have a `public/` subdir in a repository of files that you'd like to serve static files from, and a JS file for additional \"routes\" in the parent dir called `routes.js`, you'd run this server like:\n```sh\ncd public/\n../routes.js\n```\n\n## Full Example `routes.js`\n```js\n#!/usr/bin/env -S deno run --allow-net --allow-read\n\nimport main from 'https://deno.land/x/file_server_plus/mod.ts'\n\n// Any request about to 404 arrives here and you get final ability to handle/run code or 404\nglobalThis.finalHandler = (req) =\u003e {\n  const headers = new Headers()\n  try {\n    const parsed = new URL(req.url)\n    if (parsed.pathname.startsWith('/details/')) {\n      // main website /details/[SOMETHING] logical rewrite back to top page\n      headers.append('content-type', 'text/html')\n      return Promise.resolve(new Response(\n        Deno.readTextFileSync('./index.html'),\n        { status: 200, headers },\n      ))\n    }\n  } catch (error) {\n    // some kind of error -- issue 500\n    console.warn(error)\n    return Promise.resolve(new Response(`Server Error: ${error.message}`, { status: 500, headers }))\n  }\n\n  // not a route we want to handle -- issue 404\n  headers.append('content-type', 'text/html')\n  return Promise.resolve(new Response('\u003ccenter\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eNot Found\u003c/center\u003e', { status: 404, headers }))\n}\n\nmain()\n```\n\n\n## Compare [minimal changes](plus.patch) with stock [file_server.ts](https://github.com/denoland/deno_std/blob/main/http/file_server.ts)\n```sh\ncolordiff  *.ts\n```\n\n\n## Author's Note: upgrade this package to latest version of [file_server.ts](https://github.com/denoland/deno_std/blob/main/http/file_server.ts)\n```sh\n# get latest version from mothership\nwget -qO  file_server.ts \\\n  https://raw.githubusercontent.com/denoland/deno_std/main/http/file_server.ts\n\ncp  file_server.ts  mod.ts\n\n# Re-add our small modification patch into the latest stock file_server.ts.\n# ( NOTE: previously did, after intitially made manual modifications: )\n#     diff -u file_server.ts mod.ts | tee plus.patch\npatch  mod.ts  plus.patch\n\n# update these both as appropriate:\nVERSION_STD=0.155.0\nVERSION=0.2.3\n\n# change `from \"./`  strings to `from \"https://deno.land/std@$VERSION/http/`\n# change `from \"../` strings to `from \"https://deno.land/std@$VERSION/`\nperl -i -pe \"s=from \\x22./=from \\x22https://deno.land/std\\@$VERSION_STD/http/=\" mod.ts\nperl -i -pe \"s=from \\x22../=from \\x22https://deno.land/std\\@$VERSION_STD/=\"     mod.ts\n\n# review our changes\ncolordiff -U5 *.ts\n\n# Update a new version to https://deno.land/x\ngit commit -m 'updated to latest file_server.ts' .\ngit push\ngit tag         $VERSION\ngit push origin $VERSION\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finternetarchive%2Ffile_server_plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finternetarchive%2Ffile_server_plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finternetarchive%2Ffile_server_plus/lists"}