1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# `webls`

Simple file browser over HTTP

Demo: https://webls.x4204.xyz/fs/


## Prerequisites

- `python 3.12`
- `poetry`


## Setup

- create virtual environment
```
poetry env use 3.12
```

- enter virtual environment
```
poetry shell
```

- install dependencies
```
poetry install
```

- setup `storage/` directory for development and testing
```
sudo bash scripts/setup-storage.sh
```

- run tests
```
python -m tests -v
```

- run app
```
python -m webls --help
python -m webls
```


## Docker

- build image
```
docker build \
  --build-arg UID=$(id -u) \
  --build-arg GID=$(id -g) \
  --tag webls:local .
```

- run container and serve a specific host directory
```
docker run \
  --rm \
  --network=host \
  --volume /path/to/dir:/app/storage \
  webls:local
```


## TODO

- ?migrate to werkzeug
  - https://werkzeug.palletsprojects.com/en/3.0.x/

- ?support downloading a directory (with confirmation; zip)


## NOTES

- export pip requirements
```
bash scripts/export-pip-requirements.sh
```

- `templates/highlight.css` is generated by:
```python
from pygments.formatters import HtmlFormatter
print(HtmlFormatter().get_style_defs('.highlight'))
```