Posts

Showing posts from November, 2020

Backend Vlog Functionality

Image
#main.py import config from flask import Flask from controllers.index import Index from controllers.login import Login from controllers.dashboard.dashboard import Dashboard app = Flask(__name__) app.secret_key = config.vdict['secret_key'] Index.register(app, route_base='/') Login.register(app, route_base='/login') Dashboard.register(app, route_base='/dashboard') if __name__ == '__main__': app.run(debug=True) //static/scripts/dashboard.js class Lib{ load_items(url){ $('#load-more img').attr('src', '/static/images/loading.gif'); $.get(url, function(data, status){ if(status == "success"){ listing_items(data); }else{ alert('Fail to connect to server.'); } }); } getVideoForm(event){ event.preventDefault(); var json = {}; var vidType = $("input:radio[name=vid-type]:checked").val(); var videoId = $("input:text[name=vid...

Styling Posting Page

Image
#controllers/dashboard/dashboard.py from flask import session from flask_classful import FlaskView, route from controllers.dashboard.category import Category from controllers.dashboard.post import Post class Dashboard(FlaskView): def __init__(self): self.cat = Category() self.post = Post() @route('/', methods=['GET', 'POST']) def index(self): session['page'] = 0 return self.post.get_post() @route('/category/', methods=['GET', 'POST']) def category(self): session['page'] = 0 return self.cat.get_post() @route('/category/delete/<category>') def delete(self, category): return self.cat.delete(category) @route('/category/edit/<category>') def edit(self, category): return self.cat.edit(category) @route('/category/load/') def load(self): session['page'] += 1 return self.cat.load(session[...

Ajax Call Functionality

Image
#controllers/category.py import config, copy from flask import render_template, session, redirect from flask_classful import FlaskView, route from controllers.dashboard.category import Category class Dashboard(FlaskView): def __init__(self): self.cat = Category() @route('/') def index(self): vdict = copy.deepcopy(config.vdict) vdict['blog_title'] = 'ទំព័រ​គ្រប់គ្រង' if 'logged-in' in session: return render_template('dashboard/dashboard.html', data=vdict) else: return redirect('/login/') @route('/category/', methods=['GET', 'POST']) def category(self): session['page'] = 0 return self.cat.get_post() @route('/category/delete/<category>') def delete(self, category): return self.cat.delete(category) @ro...

Backend Category CRUD Functionalities

Image
#main.py import config from flask import Flask from controllers.index import Index from controllers.login import Login from controllers.dashboard.dashboard import Dashboard app = Flask(__name__) app.secret_key = config.vdict['secret_key'] Index.register(app, route_base='/') Login.register(app, route_base='/login') Dashboard.register(app, route_base='/dashboard') if __name__ == '__main__': app.run(debug=True) #controllers/category.py import config, copy from flask import render_template, session, redirect from flask_classful import FlaskView, route from controllers.dashboard.category import Category class Dashboard(FlaskView): def __init__(self): self.cat = Category() @route('/') def index(self): vdict = copy.deepcopy(config.vdict) vdict['blog_title'] = 'ទំព័រ​គ្រប់គ្រង' if 'logged-in' in session: return...

Adding Backend Category Page

Image
#main.py import config from flask import Flask, redirect from controllers.index import Index from controllers.login import Login from controllers.category import Category app = Flask(__name__) app.secret_key = config.vdict['secret_key'] Index.register(app, route_base='/') Login.register(app, route_base='/login') Category.register(app, route_base='/category') if __name__ == '__main__': app.run(debug=True) #controllers/category.py import config, copy, lib, datetime from flask import render_template, request, session, redirect from flask_classful import FlaskView, route from models.categorydb import Categorydb class Category(FlaskView): def __init__(self): self.categorydb = Categorydb() self.lib = lib.Lib() @route('/', methods=['GET', 'POST']) def category(self): vdict = copy.deepcopy(config.vdict) vdict['blog_title'] = 'បង្កើតប្រភេទមេរៀន' vdict['datetime'] = self...