#routes/admin/index.py
from bottle import Bottle
from . import post
from . import category

app = Bottle()

app.mount('/post',post.app)
app.mount('/category',category.app)

 

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

app = Bottle()

@app.route('/')
def getCategory():
    if checkLogged.call():
        from controllers.admin.categories import read
        return read.call()
    else:
        redirect('/login')

 

#controllers/admin/categories/read.py
import config
from copy import deepcopy
from bottle import template

def call():
    kdict = deepcopy(config.kdict)
    kdict['pageTitle'] = 'ទំព័រ​ជំពូក'
    kdict['route'] = '/admin/category'

    return template('base',data=kdict)

 

<!--views/admin/category.tpl-->
<link rel="stylesheet" href="/static/styles/admin/category.css" />

<form action="/admin/category" method="post">
    <input type="text" name="title" required placeholder="ឈ្មោះ​ជំពូក" />
    <input type="text" name="thumb" required placeholder="តំណរភ្ជាប់​រូប​សញ្ញា" />
    <input type="datetime-local" name="datetime" required />
    <input type="submit" value="បញ្ជូន" />
</form>

 

/* public/styles/admin/category.css */
.Index .main .content{
    background: var(--background-darker);
    padding: 20px;
}

.Index .main .content form{
    display: grid;
    grid-template-columns: 100%;
    width: 50%;
    grid-gap: 5px;
}

.Index .main .content form input{
    font: var(--body-font);
    padding: 2px 10px;
}

 

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

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