initial commit
This commit is contained in:
commit
dda9c09328
1
src/myalbum/.gitignore
vendored
Normal file
1
src/myalbum/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.JPG
|
||||
0
src/myalbum/__init__.py
Normal file
0
src/myalbum/__init__.py
Normal file
BIN
src/myalbum/__pycache__/__init__.cpython-314.pyc
Normal file
BIN
src/myalbum/__pycache__/__init__.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/myalbum/__pycache__/app.cpython-314.pyc
Normal file
BIN
src/myalbum/__pycache__/app.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/myalbum/__pycache__/models.cpython-314.pyc
Normal file
BIN
src/myalbum/__pycache__/models.cpython-314.pyc
Normal file
Binary file not shown.
24
src/myalbum/app.py
Executable file
24
src/myalbum/app.py
Executable 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
9
src/myalbum/models.py
Normal 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}"
|
||||
14
src/myalbum/templates/index.html
Normal file
14
src/myalbum/templates/index.html
Normal 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>
|
||||
Loading…
Reference in New Issue
Block a user