#routes/dashboard.py
import config
from copy import deepcopy
from bottle import Bottle, redirect, template, request
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 import index
return index.call()
else:
redirect('/')
@app.route('/logout')
def logout():
from controllers.dashboard import logout
logout.call()
@app.route('/category')
def category():
if checkLogged.call():
from controllers.dashboard import category
return category.call()
else:
redirect('/')
#controllers/dashboard/category.py
import config
from bottle import template
from copy import deepcopy
def call():
kdict = deepcopy(config.kdict)
kdict['siteLogo'] = 'ទំព័រជំពូក'
kdict['route'] = 'category'
return template('dashboard/index.tpl', data=kdict)
<!--views/dashboard/index.tpl-->
% rebase('base.tpl')
<link href="/static/styles/partials/header.css" rel="stylesheet"></link>
<section class='Head'>
<header class='region'>
<div class='site-logo'>{{ data['siteLogo'] }}</div>
<form action='/dashboard/search' method='post'>
<select name="select">
<option>ការផ្សាយ</option>
<option>ជំពូក</option>
<option>សៀវភៅ</option>
<option>អ្នកប្រើប្រាស់</option>
</select>
<input type='text' name="q" placeholder="Search" required />
<input type="submit" value='បញ្ជូន' />
</form>
<div class='logout'><a href='/dashboard/logout'>ចេញក្រៅ</a></div>
</header>
</section>
<link href="/static/styles/partials/body.css" rel="stylesheet"></link>
<section class='Body region'>
%include('dashboard/menu.tpl')
<%
if 'index' in data['route']:
include('dashboard/post.tpl')
elif 'category' in data['route']:
include('dashboard/category.tpl')
end
%>
</section>
<!--views/dashboard/category-->
<link href='/static/styles/category.css' rel='stylesheet' />
<section class='Category'>
<form action='/dashboard/category' method='post'>
<a>ឈ្មោះជំពូកៈ</a><input type='text' name="label" required />
<a>តំណរភ្ជាប់ៈ</a><input type='text' name='link' required />
<a>ពេលបង្កើតៈ</a><input type='datetime-local' name='datetime' required />
<a></a><input type='submit' value='បញ្ជូន' />
</form>
</section>
/*asset/css/category.css*/
.Category{
background: lightgrey;
}
.Category form{
display: grid;
grid-template-columns: 20% 50%;
grid-gap: 5px;
align-items: center;
margin: 20px auto;
}
.Category form a{
color: black;
text-align: right;
}
.Category form input{
font: var(--body-font);
padding: 2px 5px;
}
GitHub: https://github.com/Sokhavuth/REST-API
Vercel: https://rest-api-zeta.vercel.app