#routes/category.py
import config
from bottle import Bottle, redirect
from controllers.login import checkLogged

import bottle
bottle.BaseRequest.MEMFILE_MAX = 1024 * 1024

app = Bottle()

@app.route('/')
def index():
    if checkLogged.call():
        from controllers.dashboard.category import get
        return get.call()
    else:
        redirect('/')

@app.route('/', method='post')
def create():
    if checkLogged.call():
        from controllers.dashboard.category import create
        return create.call()
    else:
        redirect('/')

@app.route('/edit/<id>')
def edit(id):
    if checkLogged.call():
        from controllers.dashboard.category import edit
        return edit.call(id)
    else:
        redirect('/')

@app.route('/delete/<id>')
def delete(id):
    if checkLogged.call():
        from controllers.dashboard.category import delete
        return delete.call(id)
    else:
        redirect('/')

 

#controllers/dashboard/category/delete.py
import config
from bottle import template, redirect
from models.categorydb import deletedb

def call(id):
    deletedb.call(id)
    
    redirect('/dashboard/category')

 

#models/categorydb/deletedb.py
import setConnection

def call(id):
    cursor, connection = setConnection.call()

    cursor.execute("DELETE FROM category WHERE id = ?", (id,))
    
    connection.commit()
    cursor.close()

 

GitHub: https://github.com/Sokhavuth/REST-API

Vercel: https://rest-api-zeta.vercel.app