コード例 #1
0
# -*- coding: utf-8 -*-

from bson import json_util
from flask import Blueprint, request, jsonify, session

from utils import mongodb, util, redisUtils, connectionLinux, saveImage, dangRobot
from utils.config import SERVER_IP
from utils.models import User, db, Permission, Role

# 处理业务逻辑
from utils.util import filter_status

book_bp = Blueprint('book_blueprint', __name__)
mdb = mongodb.Mongodb()  # mongodb连接
reu = redisUtils.RedisClient()  # redis连接
linux = connectionLinux.LinuxConn()  # linux连接


# 加载修改注册用户的权限页面
@book_bp.route("/load_user/", methods=["POST"])
def load_user_view():
    # 接受可能的参数
    entries = request.values.get("entries")  # 每页显示条数
    uname = request.values.get("uname")  # 查询具体用户名的权限信息
    page_now = int(request.values.get("page_now"))  # 当前页面
    if str(entries).isdigit() and str(
            page_now).isdigit() and int(entries) > 0 and int(page_now) > 0:
        role_list = []
        roles = Role.query.all()
        for role in roles:
            # 根据角色id查询相应的权限
コード例 #2
0
from bp.signature_bp import signature_bp
from utils import reply, diy_menu, mongodb, CreateSign
from utils.config import APP_ID, ROOTURL, TOKENSTR
from utils.util import user_handler

app = Flask(__name__)
app.config['SECRET_KEY'] = os.urandom(24)
# 注册蓝图
app.register_blueprint(book_info_bp)
app.register_blueprint(signature_bp)
app.register_blueprint(cart_bp)

# 更新自定义菜单
diy_menu.Menu().create(diy_menu.getMenu())
# 创建mongodb连接
mdb = mongodb.Mongodb()


# 自定义过滤器
def fileter_name(li):
    if li == "未知":
        return "随便看看"
    else:
        return li


def fileter_plus(li):
    return li.replace("+", "*******")


def fileter_plus1(li):
コード例 #3
0
 def __init__(self, id, url):
     self.book_info = []
     self.id = id
     self.url = url
     self.mdb = mongodb.Mongodb()