py-lan-file-server 0.1.0__tar.gz
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.
- py_lan_file_server-0.1.0/LICENSE +21 -0
- py_lan_file_server-0.1.0/PKG-INFO +83 -0
- py_lan_file_server-0.1.0/README.md +64 -0
- py_lan_file_server-0.1.0/lan_file_server/__init__.py +5 -0
- py_lan_file_server-0.1.0/lan_file_server/__main__.py +5 -0
- py_lan_file_server-0.1.0/lan_file_server/cli.py +52 -0
- py_lan_file_server-0.1.0/lan_file_server/server.py +788 -0
- py_lan_file_server-0.1.0/lan_file_server/ui.py +1013 -0
- py_lan_file_server-0.1.0/py_lan_file_server.egg-info/PKG-INFO +83 -0
- py_lan_file_server-0.1.0/py_lan_file_server.egg-info/SOURCES.txt +14 -0
- py_lan_file_server-0.1.0/py_lan_file_server.egg-info/dependency_links.txt +1 -0
- py_lan_file_server-0.1.0/py_lan_file_server.egg-info/entry_points.txt +2 -0
- py_lan_file_server-0.1.0/py_lan_file_server.egg-info/top_level.txt +1 -0
- py_lan_file_server-0.1.0/pyproject.toml +31 -0
- py_lan_file_server-0.1.0/setup.cfg +4 -0
- py_lan_file_server-0.1.0/tests/test_server.py +223 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GGN_2015
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py-lan-file-server
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A small cross-platform LAN file upload/download server with resumable transfers.
|
|
5
|
+
Author: GGN_2015
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Framework :: AsyncIO
|
|
10
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
14
|
+
Classifier: Topic :: System :: Networking
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# py-lan-file-server
|
|
21
|
+
|
|
22
|
+
A small cross-platform Python HTTP server for sharing one folder on a local network. Start it from the command line, open the printed URL in a browser, and LAN users can upload, search, and download files.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- Clean browser UI with file search, drag-and-drop upload, size display, and modified timestamps.
|
|
27
|
+
- Live upload status over WebSocket, including uploads started by other clients.
|
|
28
|
+
- Resumable downloads through standard HTTP `Range` requests.
|
|
29
|
+
- Resumable browser uploads through chunked transfer.
|
|
30
|
+
- Upload cancellation from the originating browser client.
|
|
31
|
+
- Streaming upload and download paths, suitable for large files.
|
|
32
|
+
- Same-name uploads replace the existing file after the new upload completes.
|
|
33
|
+
- No runtime dependencies beyond the Python standard library.
|
|
34
|
+
|
|
35
|
+
## Requirements
|
|
36
|
+
|
|
37
|
+
Python 3.9 or newer.
|
|
38
|
+
|
|
39
|
+
## Run From Source
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
python -m lan_file_server --dir ./shared --host 0.0.0.0 --port 8000
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Open the URL printed in the terminal. Other devices on the same LAN can use the printed LAN address, for example `http://192.168.1.23:8000/`.
|
|
46
|
+
|
|
47
|
+
The shared directory is created automatically when it does not exist. The default directory is `./shared`.
|
|
48
|
+
|
|
49
|
+
## Install The Command
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python -m pip install .
|
|
53
|
+
lan-file-server --dir ./shared --port 8000
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Upload Resume
|
|
57
|
+
|
|
58
|
+
The web page splits files into chunks before uploading. If the browser tab is closed or the network drops, open the page again, select the same local file, and start the upload. The server continues from the bytes it already received.
|
|
59
|
+
|
|
60
|
+
Temporary upload data is stored in `.uploads` under the shared directory and is hidden from the file list. When an upload completes, the temporary file is moved atomically into the shared directory and replaces any same-name file.
|
|
61
|
+
|
|
62
|
+
## Live Uploads And Cancellation
|
|
63
|
+
|
|
64
|
+
Connected browser clients receive upload status through WebSocket. The upload panel shows active uploads from all clients and marks each row as either `This client` or `Other client`.
|
|
65
|
+
|
|
66
|
+
Only the browser client that started an upload can cancel it from the page. A manual cancellation aborts the local request and removes the server-side temporary upload file. If a connection drops unexpectedly, the active upload row is removed from connected pages and the incomplete in-flight chunk is rolled back; previously completed chunks remain available for resume.
|
|
67
|
+
|
|
68
|
+
## Download Resume
|
|
69
|
+
|
|
70
|
+
Downloads support HTTP `Range`, so browsers, download managers, and tools such as `curl -C -` can resume interrupted downloads.
|
|
71
|
+
|
|
72
|
+
## CLI
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
lan-file-server [directory] [--dir DIR] [--host HOST] [--port PORT] [--chunk-size BYTES]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Common examples:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
lan-file-server --dir ./shared
|
|
82
|
+
lan-file-server ./shared --host 0.0.0.0 --port 8000
|
|
83
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# py-lan-file-server
|
|
2
|
+
|
|
3
|
+
A small cross-platform Python HTTP server for sharing one folder on a local network. Start it from the command line, open the printed URL in a browser, and LAN users can upload, search, and download files.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Clean browser UI with file search, drag-and-drop upload, size display, and modified timestamps.
|
|
8
|
+
- Live upload status over WebSocket, including uploads started by other clients.
|
|
9
|
+
- Resumable downloads through standard HTTP `Range` requests.
|
|
10
|
+
- Resumable browser uploads through chunked transfer.
|
|
11
|
+
- Upload cancellation from the originating browser client.
|
|
12
|
+
- Streaming upload and download paths, suitable for large files.
|
|
13
|
+
- Same-name uploads replace the existing file after the new upload completes.
|
|
14
|
+
- No runtime dependencies beyond the Python standard library.
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
Python 3.9 or newer.
|
|
19
|
+
|
|
20
|
+
## Run From Source
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m lan_file_server --dir ./shared --host 0.0.0.0 --port 8000
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Open the URL printed in the terminal. Other devices on the same LAN can use the printed LAN address, for example `http://192.168.1.23:8000/`.
|
|
27
|
+
|
|
28
|
+
The shared directory is created automatically when it does not exist. The default directory is `./shared`.
|
|
29
|
+
|
|
30
|
+
## Install The Command
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
python -m pip install .
|
|
34
|
+
lan-file-server --dir ./shared --port 8000
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Upload Resume
|
|
38
|
+
|
|
39
|
+
The web page splits files into chunks before uploading. If the browser tab is closed or the network drops, open the page again, select the same local file, and start the upload. The server continues from the bytes it already received.
|
|
40
|
+
|
|
41
|
+
Temporary upload data is stored in `.uploads` under the shared directory and is hidden from the file list. When an upload completes, the temporary file is moved atomically into the shared directory and replaces any same-name file.
|
|
42
|
+
|
|
43
|
+
## Live Uploads And Cancellation
|
|
44
|
+
|
|
45
|
+
Connected browser clients receive upload status through WebSocket. The upload panel shows active uploads from all clients and marks each row as either `This client` or `Other client`.
|
|
46
|
+
|
|
47
|
+
Only the browser client that started an upload can cancel it from the page. A manual cancellation aborts the local request and removes the server-side temporary upload file. If a connection drops unexpectedly, the active upload row is removed from connected pages and the incomplete in-flight chunk is rolled back; previously completed chunks remain available for resume.
|
|
48
|
+
|
|
49
|
+
## Download Resume
|
|
50
|
+
|
|
51
|
+
Downloads support HTTP `Range`, so browsers, download managers, and tools such as `curl -C -` can resume interrupted downloads.
|
|
52
|
+
|
|
53
|
+
## CLI
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
lan-file-server [directory] [--dir DIR] [--host HOST] [--port PORT] [--chunk-size BYTES]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Common examples:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
lan-file-server --dir ./shared
|
|
63
|
+
lan-file-server ./shared --host 0.0.0.0 --port 8000
|
|
64
|
+
```
|
|
@@ -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
|