Serving a WebAssembly application using Rocket
In this section, we are going to serve the WebAssembly web application using the following steps:
- To run the WebAssembly file in
our_application
, we have to modifyour_application
a little bit. First, copy the WebAssembly and the JavaScript fromour_application_wasm/dist
to theour_application/static
directory. - Edit the template to be able to selectively use WebAssembly in
our_application/src/views/template.html.tera
as follows:<head> ... {% block wasm %}{% endblock wasm %} <meta...> </head> <body> ... {% block wasmscript %}{% endblock wasmscript %} </body>
- Add a new template file named
our_application/src/views/users/wasm.html.tera
. Edit the file in order to make sure the HTML file loads the necessary WebAssembly and JavaScript file, and run the WebAssembly on the right DOM. Add the following lines:{% extends "template"...