|
|
@ -10,7 +10,7 @@ from flask import Flask, render_template, request, redirect, url_for, flash, sen
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
from sqlalchemy.sql.expression import func, select
|
|
|
|
from sqlalchemy.sql.expression import func, select
|
|
|
|
from app.forms import UploadForm, EditForm, SearchForm
|
|
|
|
from app.forms import UploadForm, EditForm, SearchForm
|
|
|
|
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema
|
|
|
|
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns
|
|
|
|
from app.cover import get_cover
|
|
|
|
from app.cover import get_cover
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
@ -69,6 +69,11 @@ def show_books():
|
|
|
|
|
|
|
|
|
|
|
|
return render_template('show_books.html', books=books, form=search)
|
|
|
|
return render_template('show_books.html', books=books, form=search)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/updates', methods=['POST', 'GET'])
|
|
|
|
|
|
|
|
def get_updates():
|
|
|
|
|
|
|
|
userin = UserIns.query.filter_by(title="lastViewed").first()
|
|
|
|
|
|
|
|
return "XPPL /////// Last viewed: " + userin.info + " /////// "
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/scape', methods=['POST', 'GET'])
|
|
|
|
@app.route('/scape', methods=['POST', 'GET'])
|
|
|
|
def scape():
|
|
|
|
def scape():
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
@ -82,7 +87,6 @@ def scape():
|
|
|
|
return render_template('scape.html', books=books)
|
|
|
|
return render_template('scape.html', books=books)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/books_grid')
|
|
|
|
@app.route('/books_grid')
|
|
|
|
def show_books_grid():
|
|
|
|
def show_books_grid():
|
|
|
|
books = db.session.query(Book).all() # or you could have used User.query.all()
|
|
|
|
books = db.session.query(Book).all() # or you could have used User.query.all()
|
|
|
@ -91,6 +95,14 @@ def show_books_grid():
|
|
|
|
@app.route('/books/<int:id>')
|
|
|
|
@app.route('/books/<int:id>')
|
|
|
|
def show_book_by_id(id):
|
|
|
|
def show_book_by_id(id):
|
|
|
|
book = Book.query.get(id)
|
|
|
|
book = Book.query.get(id)
|
|
|
|
|
|
|
|
userin = UserIns.query.filter_by(title="lastViewed").first()
|
|
|
|
|
|
|
|
if userin != None:
|
|
|
|
|
|
|
|
userin.info = book.title
|
|
|
|
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
user_info = UserIns("lastViewed", book.title)
|
|
|
|
|
|
|
|
db.session.add(user_info)
|
|
|
|
|
|
|
|
db.session.commit()
|
|
|
|
if not book:
|
|
|
|
if not book:
|
|
|
|
return render_template('red_link.html', id=id)
|
|
|
|
return render_template('red_link.html', id=id)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|