init
This commit is contained in:
commit
5a8833d465
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.env
|
||||
__pycache__
|
||||
site
|
17
Book.py
Normal file
17
Book.py
Normal file
@ -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"""
|
||||
<tr>
|
||||
<td class="name">{self.name}</td>
|
||||
<td class="description">{self.description}</td>
|
||||
<td class="image">img/{self.image}</td>
|
||||
<td class="review">{self.review}</td>
|
||||
</tr>
|
||||
"""
|
12
cast.html
Normal file
12
cast.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<head>
|
||||
<title>My Readings</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>My Readings</h1>
|
||||
<table id="table">
|
||||
{{}}
|
||||
</table>
|
||||
</body>
|
4
constructor.json
Normal file
4
constructor.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"books": [
|
||||
]
|
||||
}
|
10
constructor_example.json
Normal file
10
constructor_example.json
Normal file
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
20
main.py
Normal file
20
main.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user