WASM test server help

I am starting to delve into WASM. I've tried running wasm-bindgen-test --chrome , but it returns "no tests to run". So, I wrote a mini test server to serve/stream HTML. It works, but I think it's just too simple for running the JS. I was hoping the mini server could stream the JS and the browser would interpret it to display it. I cannot get it to work and assuming it's my understanding of the capabilities of the server-client connection.
Could someone look this over and explain what I am missing:


use std::{
    fs, env,
    io::{prelude::*, BufReader},
    net::{TcpListener, TcpStream},

fn main() {
    let args: Vec<String> = env::args().collect();
    let listener = TcpListener::bind("").unwrap();

    for stream in listener.incoming() {
        let stream = stream.unwrap();
        match args.get(1) {
            Some(arg) => handle_connection(stream, arg ),
            None => handle_connection(stream,"C:\\Users\\ra069466\\Documents\\Software_Projects\\hello_wasm\\index.html"),


fn handle_connection(mut stream: TcpStream, args: &str) {
    let buf_reader = BufReader::new(&mut stream);
    let request_line = buf_reader.lines().next().unwrap().unwrap();

    let (status_line, filename) = if request_line == "GET / HTTP/1.1" {
        ("HTTP/1.1 200 OK", args)
    } else {
        ("HTTP/1.1 404 NOT FOUND", "404.html")

    let contents = fs::read_to_string(filename).unwrap();
    let length = contents.len();

    let response =
        format!("{status_line}\r\nContent-Length: {length}\r\n\r\n{contents}");



<!DOCTYPE html>
    <meta charset="UTF-8" />
    <title>Hello World - Rust</title>
    <script type="module" src="C:\\Users\\ra069466\\Documents\\Software_Projects\\hello_wasm\\index.js"></script>


// Import our outputted wasm ES6 module
// Which, export default's, an initialization function
import init from "C:\\Users\\ra069466\\Documents\\Software_Projects\\hello_wasm\\pkg\\hello_wasm.js";

const runWasm = async () => {
  // Instantiate our wasm module
  const helloWorld = await init("C:\\Users\\ra069466\\Documents\\Software_Projects\\hello_wasm\\pkg\\hello_wasm_bg.wasm");

  // Call the Add function export from wasm, save the result
  const addResult = helloWorld.add(24, 24);

  // Set the result onto the body
  document.body.textContent = `Hello World! addResult: ${addResult}`;

I don't think you are allowed to link to a javascript under C: if your connection is to a server under localhost. Have a look at the console and network tabs of your browser's devtools.

My main.rs was trying to build a localhost like "python3 -m http.server" command. Referencing: Compiling from Rust to WebAssembly - WebAssembly | MDN

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.