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

app = Bottle()

@app.route('/')
def getForm():
    if checkLogged.call():
        redirect('/admin/post')
    else:
        from controllers.login import get
        return get.call()

@app.route('/',method='post')
def checkUser():
    from controllers.login import checkUser
    return checkUser.call()

@app.route('/logout')
def logOut():
    if checkLogged.call():
        from controllers.login import logout
        return logout.call()
    else:
        from controllers.login import get
        return get.call()

 

#controllers/login/logout.py
import config
from bottle import response, redirect
 
def call():
    response.delete_cookie('userID', path='/', secret=config.kdict['SECRET_KEY'])
    response.delete_cookie('userRole', path='/', secret=config.kdict['SECRET_KEY'])
    redirect('/')

 

Vercel: https://khmerweb-vlog.vercel.app

GitHub: https://github.com/Sokhavuth/vlog