cargo-server
tl;dr: Does the same as "python -m http.server" or "npx serve" but for Rust ecosystem and with few more functionalities.
cargo-server
helps you serve a static site, single page application or just a static file (no matter if on your device or on the local network). It also provides a neat interface for listing the directory's contents.
You can use cargo to install:
With cargo-binstall:
Once cargo-server
is installed, you can run this command inside your project's directory. It will create by default in 8000
port:
--port
To specify the port, you can use --port
:
--open
To open in your browser after run the command just add --open
:
--path
You can also set a custom path using --path
:
Result:
--quiet
Is also possible to run without any stdout using --quiet
:
--route
You can create custom routes that returns JSON
--json
with params
Result:
--json
without params
Result:
--all-routes
It will add support for GET, POST, DELETE and PATCH methods as well.
Result:
--ngnix
In progress...