#controllers/dashboard/book/get.py
import config
from bottle import template
from copy import deepcopy
from models.bookdb import getdb
def call():
kdict = deepcopy(config.kdict)
kdict['siteLogo'] = 'ទំព័រសៀវភៅ'
kdict['route'] = 'book'
books, count = getdb.call(kdict['maxItemList'])
kdict['items'] = books
kdict['count'] = count
return template('dashboard/index.tpl', data=kdict)
#models/bookdb/getdb.py
import setConnection
def call(amount):
cursor, connection = setConnection.call()
cursor.execute("SELECT * FROM book ORDER BY datetime(datetime) DESC, rowid DESC LIMIT ?", (amount,))
books = cursor.fetchall()
cursor.execute("SELECT COUNT(*) FROM book")
count = cursor.fetchone()
cursor.close()
return books, count[0]
GitHub: https://github.com/Sokhavuth/REST-API
Vercel: https://rest-api-zeta.vercel.app