py-lan-file-server 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lan_file_server/__init__.py +5 -0
- lan_file_server/__main__.py +5 -0
- lan_file_server/cli.py +52 -0
- lan_file_server/server.py +788 -0
- lan_file_server/ui.py +1013 -0
- py_lan_file_server-0.1.0.dist-info/METADATA +83 -0
- py_lan_file_server-0.1.0.dist-info/RECORD +11 -0
- py_lan_file_server-0.1.0.dist-info/WHEEL +5 -0
- py_lan_file_server-0.1.0.dist-info/entry_points.txt +2 -0
- py_lan_file_server-0.1.0.dist-info/licenses/LICENSE +21 -0
- py_lan_file_server-0.1.0.dist-info/top_level.txt +1 -0
lan_file_server/cli.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Sequence
|
|
6
|
+
|
|
7
|
+
from .server import serve_forever
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
prog="lan-file-server",
|
|
13
|
+
description="Serve one folder on the LAN with browser upload/download support.",
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"directory",
|
|
17
|
+
nargs="?",
|
|
18
|
+
help="Folder used as the shared file collection. Defaults to ./shared.",
|
|
19
|
+
)
|
|
20
|
+
parser.add_argument(
|
|
21
|
+
"-d",
|
|
22
|
+
"--dir",
|
|
23
|
+
dest="directory_option",
|
|
24
|
+
help="Folder used as the shared file collection. Overrides the positional folder.",
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
"--host",
|
|
28
|
+
default="0.0.0.0",
|
|
29
|
+
help="Address to bind. Use 0.0.0.0 to listen on all network interfaces.",
|
|
30
|
+
)
|
|
31
|
+
parser.add_argument(
|
|
32
|
+
"-p",
|
|
33
|
+
"--port",
|
|
34
|
+
type=int,
|
|
35
|
+
default=8000,
|
|
36
|
+
help="TCP port to listen on.",
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument(
|
|
39
|
+
"--chunk-size",
|
|
40
|
+
type=int,
|
|
41
|
+
default=8 * 1024 * 1024,
|
|
42
|
+
help="Browser upload chunk size in bytes.",
|
|
43
|
+
)
|
|
44
|
+
return parser
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
48
|
+
parser = build_parser()
|
|
49
|
+
args = parser.parse_args(argv)
|
|
50
|
+
directory = Path(args.directory_option or args.directory or "shared")
|
|
51
|
+
serve_forever(directory, host=args.host, port=args.port, upload_chunk_size=args.chunk_size)
|
|
52
|
+
return 0
|