Ejemplo n.º 1
0
def check_token(token):
    """
    检测token凭证
    :param token: 登录token
    :return: boolean
    """
    data = get_config_data()
    return token == data['token.token']
Ejemplo n.º 2
0
def check_token(token):
    """
    检测token凭证
    :param token: 登录token
    :return: boolean
    """
    data = get_config_data()
    return token == data['token.token']
Ejemplo n.º 3
0
Archivo: admin.py Proyecto: Chanran/app
def login():
    """
    管理员登录
    :return:
    """
    data = get_config_data()
    username = request.forms.username
    password = request.forms.password

    if data['admin_account.username'] != username or data['admin_account.password'] != password:
        return {"code": -1}

    request.session['admin'] = datetime.datetime.now()

    return {"code": 0}
Ejemplo n.º 4
0
def login():
    """
    管理员登录
    :return:
    """
    data = get_config_data()
    username = request.forms.username
    password = request.forms.password

    if data['admin_account.username'] != username or data[
            'admin_account.password'] != password:
        return {"code": -1}

    request.session['admin'] = datetime.datetime.now()

    return {"code": 0}
Ejemplo n.º 5
0
def request_api(url, data):
    """
    请求容器API
    :param url: 容器API地址
    :param data: post参数
    :return: response对象
    """
    d = get_config_data()
    data['token'] = d['token.token']
    try:
        return requests.post(url, data, timeout=600)
    except:
        class Obj(object):
           status_code = 0
        obj = Obj()
        return obj
Ejemplo n.º 6
0
def request_api(url, data):
    """
    请求容器API
    :param url: 容器API地址
    :param data: post参数
    :return: response对象
    """
    d = get_config_data()
    data['token'] = d['token.token']
    try:
        return requests.post(url, data, timeout=600)
    except:

        class Obj(object):
            status_code = 0

        obj = Obj()
        return obj
Ejemplo n.º 7
0
模型基类
@author: yubang
"""

from peewee import Model, SqliteDatabase, MySQLDatabase
from lib.config import get_config_data


class OwnMySqlDatabase(MySQLDatabase):
    def get_conn(self):
        con = MySQLDatabase.get_conn(self)
        con.ping()
        return con


d = get_config_data()
db = OwnMySqlDatabase(database=d['mysql.db_name'], user=d['mysql.db_username'], passwd=d['mysql.db_password'],
                   host=d['mysql.db_host'], port=int(d['mysql.db_port']), charset="utf8")
sqlite_db = SqliteDatabase("data/db/base.db", threadlocals=True)


def start_connect(sqlite_db_use=True):
    return None
    db.connect()
    if sqlite_db_use:
        sqlite_db.connect()


def close_connect(sqlite_db_use=True):
    return None
    if not db.is_closed():
Ejemplo n.º 8
0
模型基类
@author: yubang
"""

from peewee import Model, SqliteDatabase, MySQLDatabase
from lib.config import get_config_data


class OwnMySqlDatabase(MySQLDatabase):
    def get_conn(self):
        con = MySQLDatabase.get_conn(self)
        con.ping()
        return con


d = get_config_data()
db = OwnMySqlDatabase(database=d['mysql.db_name'],
                      user=d['mysql.db_username'],
                      passwd=d['mysql.db_password'],
                      host=d['mysql.db_host'],
                      port=int(d['mysql.db_port']),
                      charset="utf8")
sqlite_db = SqliteDatabase("data/db/base.db", threadlocals=True)


def start_connect(sqlite_db_use=True):
    return None
    db.connect()
    if sqlite_db_use:
        sqlite_db.connect()