Skip to content

Commit 376e1db

Browse files
authored
Merge pull request #4 from hallofcodes/main
main
2 parents 7196d0b + e6ab003 commit 376e1db

35 files changed

Lines changed: 1118 additions & 445 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
venv/
2+
.venv/

__pycache__/server.cpython-312.pyc

974 Bytes
Binary file not shown.

cli.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22
import typer
3+
import stores.user_current_shared_path as shared_path
4+
import stores.share_status as share_status
35
from server import create_app
46
from waitress import serve
57
from rich.console import Console
@@ -17,9 +19,11 @@
1719

1820

1921

20-
def start_server(host: str, port: int):
22+
def start_server(host: str, port: int, path: str):
2123
app = create_app()
24+
shared_path.path = path
2225
serve(app, host=host, port=port)
26+
# app.run(debug=True)
2327

2428
# LOCAL SHARE
2529

@@ -31,6 +35,7 @@ def local_share(
3135
"""
3236
Share files instantly with anyone on your local Wi-Fi network.
3337
"""
38+
3439
if not os.path.exists(path):
3540
console.print(f"[bold red][Error][/bold red] Path '{path}' does not exist.")
3641
raise typer.Exit(code=1)
@@ -46,9 +51,9 @@ def local_share(
4651

4752
confirm_to_share_secrets_in_cwd(path)
4853

54+
share_status.status = "Offline"
4955
console.print(f"\n[bold green]Local Sharing Server started at http://{ip}:{port}[/bold green]")
50-
51-
start_server(ip, port)
56+
start_server(ip, port, path)
5257

5358
# ONLINE SHARE
5459

@@ -72,7 +77,8 @@ def remote_share(
7277
confirm_to_share_secrets_in_cwd(path)
7378

7479
host = "127.0.0.1"
75-
t = threading.Thread(target=start_server, args=(host, port), daemon=True)
80+
share_status.status = "Online"
81+
t = threading.Thread(target=start_server, args=(host, port, path), daemon=True)
7682
t.start()
7783

7884
console.print(f"[bold cyan]Server started, creating remote tunnel...[/bold cyan]")
11 Bytes
Binary file not shown.
143 Bytes
Binary file not shown.

routes/commands/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# File Operations API
2+
3+
All request and response bodies use JSON unless specified otherwise.
4+
5+
### 1. List Current Working Directory
6+
- **Endpoint:** `GET /cwd`
7+
8+
- **Response:** (Plain text) The current working directory path.
9+
10+
### 2. List Files and Directories
11+
12+
Returns a list of items inside the specified path, indicating whether each item is a file or a directory.
13+
14+
- **Endpoint:** `GET /ls`
15+
- **Query Parameters:**
16+
- `path` (string): The target directory path.
17+
- **Success Response (200 OK):**
18+
- **Content (JSON):**
19+
```json
20+
[
21+
{
22+
"name": "folder1",
23+
"type": "dir"
24+
},
25+
{
26+
"name": "file1.txt",
27+
"type": "file"
28+
}
29+
]
30+
```
31+
- **Error Response (500 Internal Server Error):**
32+
- **Content (Plain Text):** `Error listing files/directories: [error details]`
33+
34+
### 3. Copy File or Folder
35+
36+
- **Endpoint:** `POST /cp`
37+
- **Request Body:**
38+
39+
```json
40+
{
41+
"from_path": "/source/path",
42+
"dest_path": "/destination/path"
43+
}
44+
```
45+
46+
- **Response (Success - 200):** (Plain text) The path to the newly copied item.
47+
- **Response (Error - 500):** (Plain text) "Error copying file/folder: <error_details>"
48+
49+
### 4. Move File or Folder
50+
51+
- **Endpoint:** `POST /mv`
52+
- **Request Body:**
53+
54+
```json
55+
{
56+
"from_path": "/source/path",
57+
"dest_path": "/destination/path"
58+
}
59+
```
60+
61+
- **Response (Success - 200):** (Plain text) The path to the moved item.
62+
- **Response (Error - 500):** (Plain text) "Error moving file/folder: <error_details>"
1.29 KB
Binary file not shown.
585 Bytes
Binary file not shown.
1.07 KB
Binary file not shown.
1.47 KB
Binary file not shown.

0 commit comments

Comments
 (0)