Crates.io | thttp |
lib.rs | thttp |
version | 0.1.1 |
source | src |
created_at | 2020-04-10 12:45:26.790062 |
updated_at | 2020-04-10 12:45:26.790062 |
description | A minimalist static webserver written in Rust + Actix |
homepage | https://github.com/davidedelpapa/thttp |
repository | https://github.com/davidedelpapa/thttp |
max_upload_size | |
id | 228315 |
size | 52,918 |
A minimalist static webserver/fileserver written in Rust + Actix
thhtp
defaults on auditing the current (.
) directory, serving on 0.0.0.0:5050
.
USAGE:
thttp [OPTIONS] [dir]
FLAGS:
--help Prints help information
-V, --version Prints version information
OPTIONS:
-h, --host <host> Server Host [env: THTTP_HOST=] [default: 0.0.0.0]
-i, --index <index> FIle to use as index [env: THTTP_INDEX=] [default: index.html]
-p, --port <port> Server Port [env: THTTP_PORT=] [default: 5050]
ARGS:
<dir> Serving directory file [default: . ] [env: THTTP_DIR=]
Options can be specified as enviornment variables, or in a .env
file, to use in a dockerized image
The usual cargo combination:
cargo build --release
cargo run
The release is created in target/release/.
Please notice that in order to pass arguments to cargo run
you must inject a double dash (--
) between cargo run
and thttp
parameters.
For example:
cargo run -- -i readme.html -h 127.0.0.1 -p 7000 ./static
The server stops with CTRL+C
It starts always with one's needs: in this case, to port all dev stack in Rust.
While developing WASM applications I was finding myself always using the http
python module, python3 -m "http.server" "8080"
, in order to get to test the application's output.
This tool is a poor man's replacement, but it does its job.
Plus I could extend it should need arise.
The thttp
executable will look first for a socket, through listenfd, if not present it will listen normally to the host:port
.
This is useful for production environments, when using cargo-watch. Just use it in combination with systemfd
systemfd --no-pid -s http::0.0.0.0:5050 -- cargo watch -x run
See also Actix's docs on the issue.
Using cargo-watch
for the projects files is well and good, but when it's not needed, thttp
is missing the function to watch over the filesystem and reload itself for any change. This would be a good next step for the development.
MIT or Apache-2.0