Compare commits
88
Commits
b772ce8b7e
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15612eab4c | ||
|
|
949e7b84f7 | ||
|
|
5015e64bd2 | ||
|
|
ecf2aa0527 | ||
|
|
c551e69bb6 | ||
|
|
22ed8844b9 | ||
|
|
81b8825884 | ||
|
|
65f596c51c | ||
|
|
879a42039d | ||
|
|
1747045941 | ||
|
|
85fec57bb7 | ||
|
|
0516bd4a5f | ||
|
|
05b70cf94e | ||
|
|
f08844193b | ||
|
|
e389d81aeb | ||
|
|
629439043d | ||
|
|
201a78c963 | ||
|
|
458b98a870 | ||
|
|
92d855dd2a | ||
|
|
5ce5796abb | ||
|
|
6470e170f1 | ||
|
|
b1d1974704 | ||
|
|
5a2dd5f926 | ||
|
|
118140ca55 | ||
|
|
ebad87c5d1 | ||
|
|
4821bae92f | ||
|
|
387a8dc9cd | ||
|
|
d7ab7ddb13 | ||
|
|
40fa720ad9 | ||
|
|
a550667378 | ||
|
|
8317958a0f | ||
|
|
d564093193 | ||
|
|
ab304d82dc | ||
|
|
da7fa63169 | ||
|
|
1a60bd02ad | ||
|
|
bda8470f67 | ||
|
|
400cc1dc52 | ||
|
|
2fa7c04898 | ||
|
|
2e2d02340a | ||
|
|
ef93230bed | ||
|
|
3a000f2ce5 | ||
|
|
5ce5a9ede3 | ||
|
|
68828686bf | ||
|
|
d345030f86 | ||
|
|
33e0155031 | ||
|
|
f6e41aa002 | ||
|
|
e691bf5a18 | ||
|
|
5570ecacb2 | ||
|
|
1cab3d2147 | ||
|
|
02dd36aa06 | ||
|
|
38d935f8ad | ||
|
|
2bcf2dc990 | ||
|
|
f70f2854e1 | ||
|
|
0d16afae00 | ||
|
|
1f43d61524 | ||
|
|
aeb54beb27 | ||
|
|
f8c3fbee7d | ||
|
|
53925dab2c | ||
|
|
0c594872bc | ||
|
|
bd5f0bd042 | ||
|
|
934387860a | ||
|
|
b67024ab06 | ||
|
|
bff6baaa45 | ||
|
|
87ebae5a79 | ||
|
|
c2394502b5 | ||
|
|
009b2ad475 | ||
|
|
9defb4e1b2 | ||
|
|
ad8cbe211c | ||
|
|
b97c05ceb8 | ||
|
|
351934b9ed | ||
|
|
0dcb3f0d45 | ||
|
|
bcb18e8195 | ||
|
|
ee4d3dfd47 | ||
|
|
a280f5dec7 | ||
|
|
098b70fd09 | ||
|
|
1aa4712a86 | ||
|
|
d6e684a58c | ||
|
|
462b7ebdee | ||
|
|
fb327d2f9b | ||
|
|
206d4ff6a6 | ||
|
|
836f809df4 | ||
|
|
c736af6835 | ||
|
|
42e48271e2 | ||
|
|
ab5d3d6333 | ||
|
|
ccd9edf566 | ||
|
|
45ce49c246 | ||
|
|
57a9a89cd8 | ||
|
|
b5d889c478 |
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -16,6 +16,7 @@ python_requires = >=3.7
|
|||||||
install_requires =
|
install_requires =
|
||||||
aiohttp==3.10.10
|
aiohttp==3.10.10
|
||||||
dataset==1.6.2
|
dataset==1.6.2
|
||||||
|
pillow
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.4
|
||||||
Name: rupload
|
Name: rupload
|
||||||
Version: 1.3.37
|
Version: 1.3.37
|
||||||
Summary: upload tool
|
Summary: upload tool
|
||||||
@@ -9,6 +9,7 @@ Requires-Python: >=3.7
|
|||||||
Description-Content-Type: text/markdown
|
Description-Content-Type: text/markdown
|
||||||
Requires-Dist: aiohttp==3.10.10
|
Requires-Dist: aiohttp==3.10.10
|
||||||
Requires-Dist: dataset==1.6.2
|
Requires-Dist: dataset==1.6.2
|
||||||
|
Requires-Dist: pillow
|
||||||
|
|
||||||
# RUpload
|
# RUpload
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
aiohttp==3.10.10
|
aiohttp==3.10.10
|
||||||
dataset==1.6.2
|
dataset==1.6.2
|
||||||
|
pillow
|
||||||
|
|||||||
+26
-3
@@ -2,7 +2,7 @@ import pathlib
|
|||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
MAX_FILE_SIZE = 1024 * 1024 * 50 # 50Mb
|
MAX_FILE_SIZE = 1024 * 1024 * 300 # 50Mb
|
||||||
UPLOAD_FOLDER_QUOTA = 10 * 1024 * 1024 * 1024 # 10Gb
|
UPLOAD_FOLDER_QUOTA = 10 * 1024 * 1024 * 1024 # 10Gb
|
||||||
UPLOAD_URL = "/"
|
UPLOAD_URL = "/"
|
||||||
UPLOAD_PATH = "uploads"
|
UPLOAD_PATH = "uploads"
|
||||||
@@ -174,7 +174,7 @@ def format_size(size):
|
|||||||
def get_images(path):
|
def get_images(path):
|
||||||
images = []
|
images = []
|
||||||
for image in pathlib.Path(path).iterdir():
|
for image in pathlib.Path(path).iterdir():
|
||||||
if image.is_file() and image.suffix in [
|
if image.is_file() and image.suffix.lower() in [
|
||||||
".png",
|
".png",
|
||||||
".jpg",
|
".jpg",
|
||||||
".gif",
|
".gif",
|
||||||
@@ -200,7 +200,8 @@ def create_images_html(url, image_paths):
|
|||||||
images_html = ""
|
images_html = ""
|
||||||
for image_path in image_paths:
|
for image_path in image_paths:
|
||||||
path = url.rstrip("/") + "/" + image_path.name
|
path = url.rstrip("/") + "/" + image_path.name
|
||||||
images_html += f'<a href="{path}"><img class="thumbnail" src="{path}" alt="{image_path.name}" /></a>\n'
|
thumbnail_path = "/thumbnail/" + url.strip("/") + "/" + image_path.name
|
||||||
|
images_html += f'<a href="{path}"><img class="thumbnail" src="{thumbnail_path}" alt="{image_path.name}" /></a>\n'
|
||||||
return images_html
|
return images_html
|
||||||
|
|
||||||
|
|
||||||
@@ -267,6 +268,27 @@ async def handle_upload(request: web.Request):
|
|||||||
return web.Response(status=400, text="No file uploaded.")
|
return web.Response(status=400, text="No file uploaded.")
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_thumbnail(request: web.Request):
|
||||||
|
path = request.match_info["path"]
|
||||||
|
|
||||||
|
safe_path = pathlib.Path(request.app.upload_path).joinpath(pathlib.Path(path).name)
|
||||||
|
|
||||||
|
if not safe_path.is_file():
|
||||||
|
return web.Response(status=400, text="Invalid file type.")
|
||||||
|
|
||||||
|
|
||||||
|
thumbnail_path = pathlib.Path(request.app.upload_path).joinpath(".thumbnail").joinpath(pathlib.Path(safe_path).name)
|
||||||
|
if not thumbnail_path.parent.exists():
|
||||||
|
thumbnail_path.parent.mkdir(exist_ok=True,parents=False)
|
||||||
|
|
||||||
|
if not thumbnail_path.exists():
|
||||||
|
from PIL import Image
|
||||||
|
image = Image.open(safe_path)
|
||||||
|
image.thumbnail((200, 200))
|
||||||
|
image.save(thumbnail_path)
|
||||||
|
|
||||||
|
return web.FileResponse(thumbnail_path)
|
||||||
|
|
||||||
async def handle_index(request: web.Request):
|
async def handle_index(request: web.Request):
|
||||||
image_paths = get_images(request.app.upload_path)
|
image_paths = get_images(request.app.upload_path)
|
||||||
images_html = create_images_html(
|
images_html = create_images_html(
|
||||||
@@ -312,6 +334,7 @@ def create_app(
|
|||||||
web.get("/", handle_index),
|
web.get("/", handle_index),
|
||||||
web.post("/upload", handle_upload),
|
web.post("/upload", handle_upload),
|
||||||
web.static("/", upload_path),
|
web.static("/", upload_path),
|
||||||
|
web.get("/thumbnail/{path:.*}", handle_thumbnail),
|
||||||
web.static("/uploads", upload_path),
|
web.static("/uploads", upload_path),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user