Serve A Local Directory As A Static Web Site In Rust
This is old code. Check out:
https://github.com/alanwsmith/servedir
until I can get it updated.
Introduction
This is the basic code to server a directory as a website that will do an automatic hot reload when files change.
```cargo
= "0.8.1"
notify = "8.0.0"
tokio =
tower-http =
tower-livereload = "0.9.6"
```
use Html;
use get;
use Router;
use Watcher;
use Path;
use ServeDir;
use LiveReloadLayer;
async
async
axum
Notes
-
The directory that's served is defined in the
dir_to_serve
variable -
index.html
files are served if a path leads to a directory and theindex.html
file exists. -
A 404 Page Not Found is returned if no
index.html
file exist. - This is a lot like browser-sync but with way fewer features
- The main reason I running this is so I don't have to also run browser-sync at the same time. I just start up my app and it provides the core functionality as well as the web page
TODOs
[] Figure out how debouncing works or if it needs to be added.
-- end of line --
References
This is basically what I used for the sample
The docs say that using a fallback_service isn't optimal. It's what the example uses though. So, I'm going with it.