{"id":16698860,"url":"https://github.com/teascade/simplestatic","last_synced_at":"2025-04-05T04:17:25.205Z","repository":{"id":57667473,"uuid":"332853115","full_name":"Teascade/simplestatic","owner":"Teascade","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-09T11:41:10.000Z","size":124,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T13:22:42.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Teascade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-25T19:03:58.000Z","updated_at":"2023-01-22T17:19:53.000Z","dependencies_parsed_at":"2022-09-02T14:22:37.107Z","dependency_job_id":null,"html_url":"https://github.com/Teascade/simplestatic","commit_stats":null,"previous_names":["transyhdistys/simplestatic"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teascade%2Fsimplestatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teascade%2Fsimplestatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teascade%2Fsimplestatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teascade%2Fsimplestatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Teascade","download_url":"https://codeload.github.com/Teascade/simplestatic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284956,"owners_count":20913704,"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-10-12T18:04:20.680Z","updated_at":"2025-04-05T04:17:24.922Z","avatar_url":"https://github.com/Teascade.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Static\n\n![Crates.io](https://img.shields.io/crates/v/simplestatic)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/transyhdistys/simplestatic/rust)\n![GitHub](https://img.shields.io/github/license/transyhdistys/simplestatic)\n\nSimple Static is a simple http web server that serves one simple http file and other possible resources.\nThe reason for Simple Static's existance is to provide a back-end webserver for simple cases such as a maintenance\npage or a 404 page for cases where the proxy does not serve static sites itself.\n\nSimple Static is able to embed javascript and css files from given paths to the html file and also handles \nContent-Security-Policy so that any inline styles or scripts are included in the CSP for maximum security.\n\nSimple Static is also capable of serving other static content, but it's purpose is strictly to serve content\nlike images for the main html file.\n\n# Deployment\n\n## Install from cargo \n\nRun `cargo install simplestatic`\n\nAnd then just run `simplestatic`. Use `--help` for help.\n\n## Docker\n\nSimplestatic can be pulled from\n`ghcr.io/transyhdistys/simplestatic:latest`\n\nSo running it can be simple as\n`docker run -dp 3333:3333 ghcr.io/transyhdistys/simplestatic:latest`\n\nOr for docker-compose\n```yaml\nsimplestatic:\n    image: ghcr.io/transyhdistys/simplestatic:latest\n    environment:\n      - SSTATIC_PORT: 3333 # See configuring for more\n    ports:\n      - 3333:3333\n```\n\n## Build manually\n\nSimply install Rust and run `cargo run`. It should not have other dependencies, and at least Rust 1.48 is new enough.\n\n# Performance\n\nOn my personal computer when testing with [wrk](https://github.com/wg/wrk),\nSimple Static is able to serve about 150,000 requests per second, which should be plenty for anything.\n\n100 MB of RAM is probably plenty for all kinds of maintenance websites (unless\nif you're using big javascript libraries, in which case you may need more).\n\nAs for CPU I can't quite tell. A toaster should be able to run this, but with\nenough traffic it will probably eat all of the CPU you give it.\n\n## Configuring Simple Static\n\nConfiguration can be done in three different ways. \n\n| Environment Variables    | Command-Line Arguments  | config.toml     | Description\n|--------------------------|-------------------------|-----------------|------------------------------\n| `SSTATIC_HTML_PATH`      | `--html`                | `html`          | Path to the single html file.\n| `SSTATIC_JS_PATH`        | `--js`                  | `js`            | Path to the javascript file to embed, or folder containing the javascript files to embed.\n| `SSTATIC_CSS_PATH`       | `--css`                 | `css`           | Path to the css file to embed, or folder containing the css files to embed.\n| `SSTATIC_UNSAFE_INLINE`  | `--unsafe-inline`       | `unsafe_inline` | Allow usage of unsafe-inline CSP policy.\n| `SSTATIC_PORT`           | `--port`                | `port`          | Port to bind to.\n| `SSTATIC_HOST`           | `--host`                | `host`          | Host address to bind to.\n| `SSTATIC_STATIC_PATH`    | `--static-path`         | `static_path`   | Path that will serve the static content\n| `SSTATIC_STATIC_CONTENT` | `--static-content`      | `static_content`| Path of the content that will be served\n| `SSTATIC_MIME_TYPES`     | `--mime-types`          | `mime_types`    | Path to file containing mime types.\n| `SSTATIC_CONFIG_PATH`    | `--config-path`         | No option       | Path to an optional config.toml file.\n\nThe order in which these are prioritized from the first priority to last are\n1. Command-Line Arguments\n2. config.toml\n3. Environment Variables\n\nAn example toml configuration can be found at [`config.sample.toml`](config.sample.toml). The default config file is `config.toml` at working directory\nand `config.sample.toml` is configured to use the default configurations.\n\n## Templating\n\nSimple Static supports a small bit of templating in order to customize the webpage for each request.\n\n1. At the start of the program it looks for entries of `{{ js }}` and `{{ css }}` in the html file. This is where it embeds any external \njavascript and css files it finds respectively.\n2. Every time when the page is rendered, a few additional templates are filled. Refer to the table below:\n\n| What                  | Turns into          |\n|-----------------------|---------------------|\n| `{{ Host }}`          | Host -header        |\n| `{{ User-Agent }}`    | User-Agent -header  |\n\n## License\n\nSimple Static is licensed under the [AGPLv3](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteascade%2Fsimplestatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteascade%2Fsimplestatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteascade%2Fsimplestatic/lists"}