From cb849afd4ff09b9197ce4f6be286e75424b3578d Mon Sep 17 00:00:00 2001 From: Guamss Date: Mon, 23 Feb 2026 17:40:44 +0100 Subject: [PATCH] j'ai perdu mon projet --- src/myalbum/__pycache__/app.cpython-314.pyc | Bin 1393 -> 2579 bytes src/myalbum/app.py | 33 +++++++--- src/myalbum/static/styles/style.css | 61 ++++++++++++++++++ src/myalbum/templates/index.html | 66 ++++++++++++++++---- 4 files changed, 139 insertions(+), 21 deletions(-) mode change 100755 => 100644 src/myalbum/app.py create mode 100644 src/myalbum/static/styles/style.css diff --git a/src/myalbum/__pycache__/app.cpython-314.pyc b/src/myalbum/__pycache__/app.cpython-314.pyc index 8b3bcac913e577005635e5b437b6cd378053234d..fde01aa56c6fff0bcb9f37a6187356f4f93b8ab0 100644 GIT binary patch literal 2579 zcmZ`5TWlLu_RPbt_?e`RNgJA^)Ue*RHf;k9v`|*tl$g+Tm<{fa8}G!P*pu3x>76kN z5g+Cuk-|q?wNis9A|HGNiI0BlO8wvii3;(V)Pa;sDiu+&;;-H8YPElR?%0z=Y4=FJ zb6)qJbIUGR-er2DdEw{yBpe3*(GWQfD{J%4LG$Bye$+BXeqhX>}3o6N3YQ-okmP$QDJzrBz zE5T7$x}p?SL_B59vNwtuIC0S0Z0#s>TGx?A_9c)X;@Mp(w29Y{sow#D*WSug@s5)uRifj{uftEA^Z*nz02{ry?JHYwK znf6Vc{Y_PS+h>ZqzlfKx%xijcFJm!lKA3g(%gcN`BwZWHeDz`en z$$YzOW%RErgG$3cu{@~UIC$yc%B}-H#11q9Nu-zk6HDU6e{cIIOm@-FVn;;ErSgbw zfDbV{V85XUbx4A-C1{&P;{?p$vMy(DhLf>Vk1)>>B5?8+fWc>Yi6vnhIK3n>d)q*6 zb54JzB`KmuJuvb|fUG?=7+VT#+lFL6WJ3;DVnwtKBuvnD*t}DQA87gR*f)fXAVs(D zz~X4J3=!pBkIJX<9Fob1Qum`WnU@8}j^X(~I^q@`Zw91YkDil#(&3$n2S9dZ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~CwDIF#vZ@(Bys6i z`O-0M6G~~swx1{~?Bhpl$|0{rs_E~A;~LH|Jz}9eq;5C`_N5WE*<|BtHi<-8Aqw)= zuoaT=1E6V^Zz>GCKwqvo)1yMgG?9SQPhg-;5DbGN3Ri3#Ct;aCDO`)>%t{Qm<9{1+Jj diff --git a/src/myalbum/app.py b/src/myalbum/app.py old mode 100755 new mode 100644 index f0061b3..a7b6e72 --- a/src/myalbum/app.py +++ b/src/myalbum/app.py @@ -1,24 +1,41 @@ import os -from flask import Flask, render_template +from flask import Flask, render_template, request from PIL import Image from os import listdir from myalbum.models import Photo -PHOTO_DIR = "./static" +PHOTO_DIR = "./static/photos" +NUM_PHOTO_PER_PAGE = 9 app = Flask(__name__) +def create_pagination(images: list[Photo]) -> list[list[Photo]]: + return [images[i : i + NUM_PHOTO_PER_PAGE] for i in range(0, len(images), NUM_PHOTO_PER_PAGE)] + @app.route("/") def hello_world(): photos = [] paths = listdir(PHOTO_DIR) - for path in paths: + + for path in sorted(paths, reverse=True): + if not path.lower().endswith(('.png', '.jpg', '.jpeg')): + continue + img = Image.open(os.path.join(PHOTO_DIR, path)) - print(img.filename) exif_data = img.getexif() wid, hgt = img.size - brand = exif_data[271] - model = exif_data[272] - photos.append(Photo(path, str(wid) + "x" + str(hgt),brand, model)) - return render_template("index.html", photos=photos, str=str) \ No newline at end of file + brand = exif_data.get(271, "Inconnu") + model = exif_data.get(272, "Inconnu") + + photos.append(Photo(path, f"{wid}x{hgt}", brand, model)) + + pages = create_pagination(photos) + requested_page = request.args.get('page', '0') + + if requested_page.isnumeric(): + idx = int(requested_page) + if 0 <= idx < len(pages): + return render_template("index.html", pages=pages, num_page=idx, str=str) + + return render_template("index.html", pages=pages, num_page=1, str=str) \ No newline at end of file diff --git a/src/myalbum/static/styles/style.css b/src/myalbum/static/styles/style.css new file mode 100644 index 0000000..1731284 --- /dev/null +++ b/src/myalbum/static/styles/style.css @@ -0,0 +1,61 @@ +:root { + /* color-scheme: light dark; */ +} + +* { + font-family: "Roboto", sans-serif; +} + +main { + display: flex; + flex-direction: column; + align-items: center; + border: 1px solid black; + padding: 2rem; +} + +.pictures { + display: flex; + flex-wrap: wrap; + gap: 2rem; + justify-content: center; + width: 100%; +} + +.img-link { + display: flex; + flex-direction: column; + align-items: center; + text-decoration: none; + color: black; + width: calc((100% / 3) - 2rem); + transition: transform .2s; +} + +.img-link:hover { + transform: scale(1.05); +} + +.picture { + width: 100%; + height: auto; + object-fit: cover; +} + +.pagination { + display: flex; + justify-content: center; + gap: 1rem; +} + +@media screen and (max-width: 80rem) { + .img-link { + width: calc(50% - 2rem); + } +} + +@media screen and (max-width: 40rem) { + .img-link { + width: 100%; + } +} \ No newline at end of file diff --git a/src/myalbum/templates/index.html b/src/myalbum/templates/index.html index 1a45bea..294793b 100644 --- a/src/myalbum/templates/index.html +++ b/src/myalbum/templates/index.html @@ -1,14 +1,54 @@ - + - - - - Document - - - {% for photo in photos %} - -

{{ str(photo) }}

- {% endfor %} - - \ No newline at end of file + + + + + Guams's album + + + +
+

Note : Toutes les personnes présentes sur les photos consentent à apparaître sur cette page

+
+ {% for photo in pages[num_page - 1] %} + + {{ photo.name }} +

{{ photo | string }}

+
+ {% endfor %} +
+ +
+ +