0

I'm setting up an Actix server that will host a variety of static files with the traffic of the web applications running through this single server. When I try to serve a file however, it will serve my assets folder and my HTML file but not my JavaScript file.

I've tried using NamedFile to no advantage and I have tried using "./index.js", "index.js", and moving it to its own js folder and trying "js/index.js".

main.rs

HttpServer::new(|| {
    App::new()
        .service(
            web::scope("/")
            // Checksheet
                .service(
                    web::scope("/checksheet")
                        .route("/save", web::get().to(save_checksheet))
                        .service(
                            fs::Files::new("", "./quality- 
                            checksheet/public/")
                               .index_file("index.html")
                        )                            
                 )

index.html

<meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Quality Checksheet</title>
    <script src="index.js"></script>
    <link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">

Project Structure

.
+-- src
|   +-- main.rs
+-- checksheet
|   +-- public
|       +-- assets
|           +-- badge.img
|       +-- index.html
|       +-- index.js

When my server is launched and you go to the page the index.js file is empty, but the assets folder has the images used in the page and the index.html page is displaying.

Ray Kochenderfer
  • 333
  • 1
  • 6
  • 15

0 Answers0