commit 5a8833d465d04583b66e94d0854c766ff3477cc8 Author: starnakin Date: Mon Aug 5 21:14:49 2024 +0200 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1a48d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env +__pycache__ +site \ No newline at end of file diff --git a/Book.py b/Book.py new file mode 100644 index 0000000..15f03e6 --- /dev/null +++ b/Book.py @@ -0,0 +1,17 @@ +class Book: + + def __init__(self, name: str, description: str, image: str, review: str) -> None: + self.name: str = name + self.description: str = description + self.image: str = image + self.review: str = review + + def to_html(self) -> str: + return f""" + + {self.name} + {self.description} + img/{self.image} + {self.review} + + """ \ No newline at end of file diff --git a/cast.html b/cast.html new file mode 100644 index 0000000..d76a1f2 --- /dev/null +++ b/cast.html @@ -0,0 +1,12 @@ + + + + My Readings + + + +

My Readings

+ + {{}} +
+ \ No newline at end of file diff --git a/constructor.json b/constructor.json new file mode 100644 index 0000000..521571e --- /dev/null +++ b/constructor.json @@ -0,0 +1,4 @@ +{ + "books": [ + ] +} \ No newline at end of file diff --git a/constructor_example.json b/constructor_example.json new file mode 100644 index 0000000..51b7a86 --- /dev/null +++ b/constructor_example.json @@ -0,0 +1,10 @@ +{ + "books": [ + { + "name": "1984", + "description": "1984 est un roman dystopique de l'écrivain britannique George Orwell. Publié le 8 juin 1949 par Secker & Warburg, il s'agit du neuvième et dernier livre d'Orwell achevé de son vivant", + "image": "1984.jpg", + "review": "ct pas mal" + } + ] +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..07894ab --- /dev/null +++ b/main.py @@ -0,0 +1,20 @@ +import json +from Book import Book + +# Opening JSON file +f = open('constructor.json') + +data = json.load(f) + +f.close() + +books = data['books'] +html = "" + +for book_data in books: + book = Book(book_data["name"], book_data["description"], book_data["image"], book_data["review"]) + html += book.to_html() + +f = open("cast.html") +print(f.read().replace("{{}}", html)) +f.close() \ No newline at end of file