Домашняя страница
Страница чтения, изображение будет показано слева
Бэкенд и логика книги написаны на Python и Pandas.
Чтобы открыть программу чтения с изображениями разных книг, мне нужно направить каждый элемент div через '/reader'+id, где идентификатор каждого элемента div является идентификатором соответствующего PDF-файла.
Код: Выделить всё
{% for book in books %}
[img]{{ url_for([/img]
{{ book['Name'] }}
{{ book['Author'] }}
{{ book['Date'] }} · {{ book['Genre'] }}
{% endfor %}
Код: Выделить всё
@app.route('/reader/')
def reader(book_id):
book_row = books_df[books_df['ID'] == book_id]
if not book_row.empty:
last_page = book_row['Last_page'].idxmax()
last_page_image_path = str(pdf_to_image("Server/Books/"+str(book_row.iloc[0]['Name']+".pdf"), last_page, 150))
print(f"Path to Image: {last_page_image_path}")
return render_template('reader.html', book_id=book_id, last_page_image=last_page_image_path)
else:
return "Book not found"
"GET /reader/static/Images/1.png HTTP/1.1" 404 -
Даже когда я делаю еще одну папка под названием Reader, похоже, она не работает.
Ссылка на мой проект:
Код: Выделить всё
Backend_Scripts
-rendered.py (contains logic to convert page into image)
-Basic_logic.py (Contains Book and Library Classes)
Server
-books(folder)
-.lib (datafile, books table)
static
-icons
--icons files
-Images
--this is where i want to generate the pages
-Thumbnails
--Book Thumbnails
-CSS Files
templates
-main.html
-reader.html
app.py
Подробнее здесь: https://stackoverflow.com/questions/782 ... lask-route