Skip to content

Commit a3624ff

Browse files
committed
update README.md
1 parent 2856e85 commit a3624ff

File tree

5 files changed

+98
-36
lines changed

5 files changed

+98
-36
lines changed

Cargo.lock

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,63 @@ fileserver-rs
22
=============
33

44
Simple file server written in Rust.
5+
6+
![fileserver-rs](https://github.com/neevek/fileserver-rs/raw/master/screenshot/screenshot.jpg)
7+
8+
Build from source
9+
-----------------
10+
11+
1. build the `frontend` crate:
12+
13+
`frontend` will be built with the `trunk` program, which can be installed with `cargo install trunk`, see [trunkrs.dev](https://trunkrs.dev/) for details.
14+
15+
```
16+
cd frontend
17+
trunk build --release --public-url '/assets'
18+
```
19+
20+
The `index.html` file and the generated wasm files will be copied to `frontend/dist`, these files will be used to render the frontend UI, to interact with the backend server.
21+
22+
23+
2. build the `backend` crate:
24+
25+
`cargo build --release --bin fileserver-rs`
26+
27+
output of the `backend` crate is named `fileserver-rs`, which will be built as a command line app and located at `target/release/fileserver-rs`:
28+
29+
30+
```
31+
A static file server that supports upload/create dir/delete/qrcode
32+
33+
Usage: fileserver-rs [OPTIONS]
34+
35+
Options:
36+
-l, --log <LOG_LEVEL> Log level [default: debug]
37+
-a, --addr <ADDR> Listen addr [default: 0.0.0.0]
38+
-p, --port <PORT> Listen port [default: 8888]
39+
--assets-dir <ASSETS_DIR> Directory where the wasm files built from the frontend sub crate are located [default: ./frontend/dist]
40+
--serve-dir <SERVE_DIR> Directory to serve, default to the current directory if not specified [default: .]
41+
-h, --help Print help information
42+
43+
```
44+
45+
Run the server
46+
--------------
47+
48+
Run the server to serve the `target` directory (this is for test):
49+
50+
`
51+
./target/release/fileserver-rs -p 8888 --assets-dir ./frontend/dist --serve-dir ./target
52+
`
53+
54+
Now the server is started at `http://localhost:8888/`.
55+
56+
MIT License
57+
-------
58+
Copyright 2022 Jiamin.Xie
59+
60+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
61+
62+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
63+
64+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "backend"
2+
name = "fileserver-rs"
33
version = "0.1.0"
44
edition = "2021"
55

backend/src/main.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,29 @@ use walkdir::WalkDir;
2626

2727
static mut SERVE_DIR: Option<PathBuf> = None;
2828

29-
// Setup the command line interface with clap.
3029
#[derive(Parser, Debug)]
31-
#[clap(name = "server", about = "A server for our wasm project!")]
30+
#[clap(
31+
name = "fileserver-rs",
32+
about = "A static file server that supports upload/create dir/delete/qrcode"
33+
)]
3234
struct Opt {
33-
/// set the log level
35+
/// Log level
3436
#[clap(short = 'l', long = "log", default_value = "debug")]
3537
log_level: String,
3638

37-
/// set the listen addr
39+
/// Listen addr
3840
#[clap(short = 'a', long = "addr", default_value = "0.0.0.0")]
3941
addr: String,
4042

41-
/// set the listen port
42-
#[clap(short = 'p', long = "port", default_value = "8080")]
43+
/// Listen port
44+
#[clap(short = 'p', long = "port", default_value = "8888")]
4345
port: u16,
4446

45-
/// set the directory where static files are to be found
46-
#[clap(long = "assets-dir", default_value = "../assets")]
47+
/// Directory where the wasm files built from the frontend sub crate are located
48+
#[clap(long = "assets-dir", default_value = "./frontend/dist")]
4749
assets_dir: String,
4850

49-
/// the directory to serve, default to the current directory if not specified
51+
/// Directory to serve, default to the current directory if not specified
5052
#[clap(long = "serve-dir", default_value = ".")]
5153
serve_dir: String,
5254
}

screenshot/screenshot.jpg

69.7 KB
Loading

0 commit comments

Comments
 (0)