Skip to content

Commit 4fe0058

Browse files
authored
Merge pull request #29 from WebisD/feat_find_files
Feat find files
2 parents db5bc1d + 67adabb commit 4fe0058

File tree

11 files changed

+51
-30
lines changed

11 files changed

+51
-30
lines changed
-125 KB
Binary file not shown.
-125 KB
Binary file not shown.
-125 KB
Binary file not shown.
-704 KB
Binary file not shown.

databaseUser/Images/images.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
"type": "image/jpg",
2424
"filePath": "./databaseUser/Images/07052021000202.jpg"
2525
}
26-
},
27-
{
28-
"/08052021120359.png": {
29-
"type": "image/png",
30-
"filePath": "./databaseUser/Images/08052021120359.png"
31-
}
3226
}
3327
]
3428
}

databaseUser/database.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@
3131
"pokemon": "Giant",
3232
"image": "/07052021000202.jpg"
3333
}
34-
},
35-
{
36-
"08052021120359": {
37-
"name": "Ashe",
38-
"phone": "1196632651",
39-
"pokemon": "Charmander",
40-
"image": "/08052021120359.png"
41-
}
4234
}
4335
]
4436
}

handler/HandlerRequests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def recv(sock, chunkSize=8192):
2121
while True:
2222
data = sock.recv(chunkSize)
2323

24-
if data is None:
25-
return
24+
if data is None or data == b'':
25+
continue
2626

2727
try:
2828
decoded_data = data.decode()

handler/findFile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import fnmatch
2+
import os
3+
4+
5+
def find(pattern, path):
6+
result = []
7+
for root, dirs, files in os.walk(path):
8+
for name in files:
9+
if fnmatch.fnmatch(name, pattern):
10+
result.append(os.path.join(root, name))
11+
return result
12+

message/Response.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ def encodeResponse(self):
1515

1616
return response.encode()
1717

18-
def encodeResponseImages(self):
18+
def encodeResponseImages(self, image, new_path=None):
1919
response = ""
2020
response += self.statusLine() + "\n"
2121
response += self.headerLine()
2222
response += self.server + "\n"
2323
response += "\n"
24-
#esponse = response.encode()
24+
25+
print(f'Image -> {image}: {self.status_code.value[0]} {self.status_code.value[1]}')
26+
if self.status_code.value[0] == "301" and new_path is not None:
27+
print(5*" " + f"New path: {new_path}")
2528

2629
return response.encode() + self.body
2730

message/StatusCode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class StatusCode(enum.Enum):
99
RESET_CONTENT = ["205", "Reset Content"]
1010
# Redirection 3xx
1111
MULTIPLE_CHOICES = ["300", "Multiple Choices"]
12+
MOVED_PERMANENTLY = ["301", "Moved Permanently"]
1213
NOT_MODIFIED = ["304", "Not Modified"]
1314
# Client Error 4xx
1415
BAD_REQUEST = ["400", "Bad Request"]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy