2024-08-05 15:14:49 -04:00
|
|
|
import json
|
|
|
|
from Book import Book
|
|
|
|
|
|
|
|
# Opening JSON file
|
2024-08-05 15:28:24 -04:00
|
|
|
f = open('constructor.json', encoding='utf-8')
|
2024-08-05 15:14:49 -04:00
|
|
|
data = json.load(f)
|
2024-08-05 15:37:29 -04:00
|
|
|
f.close()
|
|
|
|
f = open("style.css")
|
|
|
|
style = f.read()
|
2024-08-05 15:14:49 -04:00
|
|
|
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")
|
2024-08-05 15:37:29 -04:00
|
|
|
print(f.read().replace("{{books}}", html).replace("{{style}}", style))
|
2024-08-05 15:14:49 -04:00
|
|
|
f.close()
|