{"id":13708730,"url":"https://github.com/deislabs/wagi-fileserver","last_synced_at":"2025-08-11T06:12:52.136Z","repository":{"id":44641045,"uuid":"373893821","full_name":"deislabs/wagi-fileserver","owner":"deislabs","description":"A static file server for Wagi written in Grain","archived":false,"fork":false,"pushed_at":"2022-10-18T23:37:36.000Z","size":67,"stargazers_count":32,"open_issues_count":3,"forks_count":7,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-08T07:16:48.938Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Makefile","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/deislabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-04T16:00:55.000Z","updated_at":"2024-02-03T15:37:34.000Z","dependencies_parsed_at":"2023-01-20T04:31:37.663Z","dependency_job_id":null,"html_url":"https://github.com/deislabs/wagi-fileserver","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/deislabs/wagi-fileserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deislabs%2Fwagi-fileserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deislabs%2Fwagi-fileserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deislabs%2Fwagi-fileserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deislabs%2Fwagi-fileserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deislabs","download_url":"https://codeload.github.com/deislabs/wagi-fileserver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deislabs%2Fwagi-fileserver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269838454,"owners_count":24483204,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-02T23:00:31.708Z","updated_at":"2025-08-11T06:12:52.093Z","avatar_url":"https://github.com/deislabs.png","language":"Makefile","funding_links":[],"categories":["Applications"],"sub_categories":[],"readme":"# Fileserver-gr\n\nA [Wagi](https://github.com/deislabs/wagi) static fileserver written in Grain.\n\n\u003e DeisLabs is experimenting with many WASM technologies right now.\n\u003e This is one of a multitude of projects designed to test the limits\n\u003e of WebAssembly as a cloud-based runtime. This code is not stable or\n\u003e production ready.\n\n## Getting a Binary\n\nWe periodically release Wasm modules in binary form. To get the latest, go to the [releases page](https://github.com/deislabs/wagi-fileserver/releases). In the future, we will also publish bindles.\n\n## Building and Running Locally\n\nYou will need the [Grain](https://grain-lang.org) toolkit to work with this repo.\n\nTo run:\n\n```console\n$ make run \n```\n\nTo compile:\n\n```console\n$ make build\n```\n\nYou can run unit tests with `make test-unit` or full tests with `make test`:\n\n```\n$ make test\ngrain compile fileserver.gr\ngrain tests.gr\n✅ PASS         Env.splitEnvVar should parse\n✅ PASS         Util.reverse should reverse string\n✅ PASS         Util.lastIndexOf should find Some\n===== Expected: =====\nSome(19)\n======= Got: ========\nSome(18)\n=====================\n⛔️ FAIL         UtillastIndexOf should find Some\n✅ PASS         Util.lastIndexOf should find None\n✅ PASS         Mediatype.guess should find text/plain\n✅ PASS         Mediatype.guess should find default type\n❌ Total failed tests: 1❌\nmake: *** [test-unit] Error 1\n```\n\n## Running in Wagi\n\nYou have two options for running in Wagi:\n\n1. Use [hippofactory](https://github.com/deislabs/hippofactory) to build and push a bindle, then use `wagi -b $YOUR_BINDLE`\n2. Write a `modules.toml` file and use `wagi -c modules.toml`.\n\n### Using `hippofactory`\n\nEdit the `HIPPOFACTS` file to taste.\n\nTo use `hippofactory`, you can just run this command from the repo root:\n\n```console\n$ hippofactory -s http://localhost:8080/v1 .\npushed: fileserver/0.1.0-technosophos-2021.06.03.17.25.54.484\n```\n\nThen run it in Wagi like this:\n\n```console\n$ wagi -b fileserver/0.1.0-technosophos-2021.06.03.17.25.54.484 --bindle-server http://localhost:8080/v1\n[2021-06-03T23:26:54Z INFO  wagi] =\u003e Starting server on 127.0.0.1:3000\n[2021-06-03T23:26:54Z DEBUG wagi::runtime::bindle] loaded 1 modules from the default group (parcels that do not have conditions.memberOf set)\n[2021-06-03T23:26:54Z DEBUG wagi::runtime] module cache miss. Loading module parcel:fileserver/0.1.0-technosophos-2021.06.03.17.25.54.484#110f6f54401b80d9d80dae9257969468a5a70248dba8d96ce74b9bc5bc104fdd from remote.\n[2021-06-03T23:26:54Z INFO  wagi::runtime] (load_routes) instantiation time for module parcel:fileserver/0.1.0-technosophos-2021.06.03.17.25.54.484#110f6f54401b80d9d80dae9257969468a5a70248dba8d96ce74b9bc5bc104fdd: 107.802106ms\n```\n\n### Using `modules.toml`\n\nHere is an example `modules.toml` for [Wagi](https://github.com/deislabs/wagi):\n\n```toml\n[[module]]\nroute = \"/static/...\"\nmodule = \"/path/to/fileserver/fileserver.gr.wasm\"\nvolumes = {\"/\" = \"/path/to/fileserver\"}\n```\n\nThe above configures Wagi to map the path `/static/...` to the `fileserver.gr.wasm` module. Then it serves all of the files in this project.\n\n### Environment Variables\n\nThe following environment variables can be passed via Wagi's `-e` flag:\n\n- `CACHE_CONTROL`: The string value of a cache-control header. If not specified, this will set cache-control to `no-cache`. Google recommends setting this value to `CACHE_CONTROL=\"max-age=31536000\"` (cache for up to 1 year).\n- Type-specific cache controls can be set using the following env vars (all of which default to `CACHE_CONTROL` if not set):\n    - `CSS_CACHE_CONTROL`\n    - `FONT_CACHE_CONTROL`\n    - `IMAGE_CACHE_CONTROL`\n    - `JS_CACHE_CONTROL`\n\n\n### Testing the Static Fileserver with `curl`\n\nThis step is the same whether you use Bindle or a `modules.toml`.\n\nAssuming you have Wagi running on `http://localhost:3000`, you can then run this command:\n\n```console\n$ curl -v localhost:3000/static/LICENSE.txt\n*   Trying 127.0.0.1...\n* TCP_NODELAY set\n* Connected to localhost (127.0.0.1) port 3000 (#0)\n\u003e GET /static/LICENSE.txt HTTP/1.1\n\u003e Host: localhost:3000\n\u003e User-Agent: curl/7.64.1\n\u003e Accept: */*\n\u003e\n\u003c HTTP/1.1 200 OK\n\u003c content-type: text/plain\n\u003c content-length: 1104\n\u003c date: Fri, 04 Jun 2021 00:16:14 GMT\n\u003c\nThe MIT License (MIT)\n\nCopyright (c) Microsoft Corporation. All rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE\n* Connection #0 to host localhost left intact\n* Closing connection 0\n```\n\nThe fileserver took `/static/filserver.gr`, removed the `/static/` part from the front, and then loaded `fileserver.gr` from the directory mounted in the `modules.toml`. Note that any subdirectories are also served. So `/static/foo/bar` would translate to the path `foo/bar` inside of the WebAssembly module (which in the example above would fully resolve to \"/path/to/fileserver/foo/bar\").\n\n## Prefixing a Path\n\n`PATH_PREFIX` is an environment variable you can set.\nThis allows you to add `-e PATH_PREFIX=/some/prefix` as an env var to `fileserver.gr.wasm`.\n\nThis will allow the fileserver to set a specific path prefix for files before it looks them up. So instead of doing `http://example.com/static/static/foo.png`, you can set `wagi -e PATH_PREFIX=static/` and then `http://example.com/static/foo.png` will resolve on the filesystem, to `static/foo.png` instead of `foo.png`.\n\n## Security Note\n\nThe Wagi fileserver is designed to serve any file mounted in the volume. Do not mount a\nvolume that contains files you do not want served.\n\n## Code of Conduct\n\nThis project has adopted the [Microsoft Open Source Code of\nConduct](https://opensource.microsoft.com/codeofconduct/).\n\nFor more information see the [Code of Conduct\nFAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact\n[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional\nquestions or comments.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeislabs%2Fwagi-fileserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeislabs%2Fwagi-fileserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeislabs%2Fwagi-fileserver/lists"}