def read_img(image_name):
    #连接数据库
    manager_sql = select_insert_db.ManagerMysql(table_name="photo_infomation",
                                                user_name=session["user_name"])
    #获得路径
    image_path = manager_sql.get_user_own_img_path(image_name)
    session["image_path"] = image_path
Example #2
0
def up_load_photo():
    #创建数据库对象,
    manager_sql=select_insert_db.ManagerMysql(table_name="photo_infomation",
                                              user_name=session["user_name"],
                                              img_ascription=session["user_name"],
                                              img_path=session["file_path"],
                                              img_size=session["file_size"],
                                              image_name=session["file_title"])
    result=manager_sql.add_infomation()
    #将数据插入到数据库中,返回True
    return result
Example #3
0
def read_img(image_name):
    #连接数据库
    manager_sql=select_insert_db.ManagerMysql(table_name="photo_infomation",user_name=session["user_name"])
    #获得路径
    image_path=manager_sql.get_user_own_img_path(image_name)
    session["image_path"]=image_path
    #返回图片
    try:
        f=open(image_path,"rb")
    except Exception:
        return "您好数据出问题啦!".encode("utf-8")
    else:
        image_content=f.read()
        return image_content
def get_img_title():
    # app.logger.warning("4444444")
    # 连接数据库
    manager_sql = select_insert_db.ManagerMysql(table_name="photo_infomation",
                                                user_name=session["user_name"])
    #从数据库取得图片的标题
    # app.logger.warning("55555555")
    app.logger.info("--get_img _title")
    app.logger.info(session["img_count"])
    img_title_list = manager_sql.get_user_own_img_title(session["img_count"])
    # app.logger.warning("66666666")
    # session["img_count"]+=len(img_title_list)
    # 直接返回图片的标题
    if len(img_title_list) <= 0:
        return ""
    return json.dumps(img_title_list)
Example #5
0
def handle_data(task, username, password, ):

    app.logger.info("来到数据处理啦")
    '''哈希加密,对数据进行哈希加密,并调用相关的处理方法,操作成功返回True,操做失败返回False'''
    ha_password = hashlib.md5(password.encode("utf-8")).hexdigest()
    app.logger.info(type(ha_password))
    # 创建数据库管理对象,
    manager_sql = select_insert_db.ManagerMysql(table_name="user_infomation", user_name=username, password=ha_password)
    # 根据调用的函数,选择合适的操作,返回True或者
    if task == "register":
        result = manager_sql.add_infomation()
    elif task == "login":
        result = manager_sql.retrieve()
    else:
        result = False
    manager_sql.close_mysql_connect()
    return result