Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ttys3/static-server
simple static file server written in Rust based on axum framework
https://github.com/ttys3/static-server
async axum file-server rust static-server tokio tower-http
Last synced: 7 days ago
JSON representation
simple static file server written in Rust based on axum framework
- Host: GitHub
- URL: https://github.com/ttys3/static-server
- Owner: ttys3
- Created: 2021-08-21T11:55:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-24T03:08:15.000Z (10 days ago)
- Last Synced: 2024-12-24T04:18:42.712Z (10 days ago)
- Topics: async, axum, file-server, rust, static-server, tokio, tower-http
- Language: Rust
- Homepage:
- Size: 331 KB
- Stars: 62
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# static-server
simple static file server written in Rust based on [axum](https://github.com/tokio-rs/axum) framework![screenshot](https://user-images.githubusercontent.com/41882455/144649440-d7e66a57-d6cb-4070-bb60-a0003e3d3d67.png)
I'm learning Rust and axum.
My thought is simple.
axum has a [static-file-server](https://github.com/tokio-rs/axum/tree/main/examples/static-file-server) example, which only serve static files under a directory and does not list the directory index.
it also has a [templates](https://github.com/tokio-rs/axum/tree/main/examples/templates) example which uses askama as template engine to parse a Jinja2 like template.
I thought I could simply combine the code of the two and my job is done -_-
But things didn't go in the way I thought
## why created this ?
long time ago, I used to start a static http server like this (using the python3 built-in http server) :
```shell
python3 -m http.server -d .
```
since I'm learning Rust, and I found an interesting web framework that is `Axum`, I want to use Axum to implement a simple static server mainly for studying purposes.the python one support some command line flags:
```shell
❯ python3 -m http.server -h
usage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [port]positional arguments:
port Specify alternate port [default: 8000]optional arguments:
-h, --help show this help message and exit
--cgi Run as CGI Server
--bind ADDRESS, -b ADDRESS
Specify alternate bind address [default: all interfaces]
--directory DIRECTORY, -d DIRECTORY
Specify alternative directory [default:current directory]
```so does this one:
```shell
❯ static-server -h
static-server 0.4.2
A simple static file server written in Rust based on axum framework.USAGE:
static-server [OPTIONS]FLAGS:
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
-a, --addr set the listen addr [default: 127.0.0.1]
-l, --log set the log level [default: debug]
-p, --port set the listen port [default: 3000]
-r, --root set the root directory [default: .]
```## TODO
use https://github.com/sampotts/plyr for audio,video
https://github.com/tokio-rs/axum/blob/main/axum/CHANGELOG.md
## Related Projects
https://github.com/eliben/static-server