Code Monkey home page Code Monkey logo

wasm-server-runner's Introduction

wasm-server-runner

Allows you to run programs in the browser using web assembly using a simple cargo run.

Usage

Step 1.

rustup target add wasm32-unknown-unknown
cargo install wasm-server-runner

Step 2.

Add this to your ~/.cargo/config.toml (not the Cargo.toml of your project!):

[target.wasm32-unknown-unknown]
runner = "wasm-server-runner"

Step 3.

Run programs in the browser using

cargo run --target wasm32-unknown-unknown
cargo run --target wasm32-unknown-unknown --example example

wasm-server-runner path/to/file.wasm

Example output:

INFO wasm_server_runner: wasm output is 49.79kb large
INFO wasm_server_runner: starting webserver at http://127.0.0.1:1334

The website will reload when the server is restarted and serve files relative to the current directory.

Configuration options

All configuration options can be specified via environment variables.

WASM_SERVER_RUNNER_ADDRESS

Default: 127.0.0.1 Control the address that the server listens on. Set to 0.0.0.0 to allow access from anywhere.

WASM_SERVER_RUNNER_DIRECTORY

Default: .

Can be used to specify where relative path requests are loaded from.

WASM_SERVER_RUNNER_CUSTOM_INDEX_HTML

Default: none

When set, will try to load the custom index.html from that path instead of the default. Can be relative to the directory.

Note: To support both module and non-module style the index.html needs to have specific string that will be replaced at runtime. The body should contain something like

{{ NO_MODULE }}
<script type="module">
    // {{ MODULE }}
</script>
WASM_SERVER_RUNNER_HTTPS

Default: false

Controls whether https is used.

WASM_SERVER_RUNNER_NO_MODULE

Default: false

Controls whether the wasm-bindgen output uses modules or not.

wasm-server-runner's People

Contributors

jakobhellermann avatar daxpedda avatar squ1dd13 avatar supercilex avatar jad3n avatar johanhelsing avatar mousetail avatar totalkrill avatar ambiso avatar jabuwu avatar lee-orr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.