initial commit

This commit is contained in:
Guamss 2026-02-23 00:05:32 +01:00
commit dda9c09328
8 changed files with 48 additions and 0 deletions

1
src/myalbum/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.JPG

0
src/myalbum/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

24
src/myalbum/app.py Executable file
View File

@ -0,0 +1,24 @@
import os
from flask import Flask, render_template
from PIL import Image
from os import listdir
from myalbum.models import Photo
PHOTO_DIR = "./static"
app = Flask(__name__)
@app.route("/")
def hello_world():
photos = []
paths = listdir(PHOTO_DIR)
for path in paths:
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)

9
src/myalbum/models.py Normal file
View File

@ -0,0 +1,9 @@
class Photo():
def __init__(self, name: str, res: str, brand: str, model: str) -> None:
self.name = name
self.res = res
self.brand = brand
self.model = model
def __str__(self) -> str:
return f"{self.name} {self.res}"

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
{% for photo in photos %}
<img src="{{ url_for('static', filename=photo.name) }}">
<p>{{ str(photo) }}</p>
{% endfor %}
</body>
</html>