Exemplo n.º 1
0
    def post(self):
        try:
            self.timeClass = Utils.Time()
            self.parser = reqparse.RequestParser()
            self.ai = AI.AI()
            self.openid = request.headers['Openid']
            self.file = request.files['file']
            self.file_name = self.file.filename
            self.list = self.file_name.split('.')
            self.m2 = hashlib.md5()
            self.m2.update((str(self.timeClass.get_time()) +
                            self.file_name).encode("utf8"))
            self.file_name = self.m2.hexdigest() + "." + self.list[
                len(self.list) - 1]
            self.path = "templates\\"
            self.file.save(self.path + self.file_name)
            self.restatus = self.ai.ai_pic(self.path, self.file_name,
                                           self.openid)
            # try:
            #     os.remove(self.file_name)
            # except Exception as e:
            #     print(e)
            return self.restatus, 200

        except Exception as e:
            print(e)
            return {"code": -1, "data": {"msg": str(e)}}, 500
Exemplo n.º 2
0
    def post(self):
        try:
            self.timeClass = Utils.Time()
            self.parser = reqparse.RequestParser()
            self.file = request.files['file']
            self.file_name = self.file.filename
            self.list = self.file_name.split('.')
            self.m2 = hashlib.md5()
            self.m2.update((str(self.timeClass.get_time()) +
                            self.file_name).encode("utf8"))
            self.file_name = self.m2.hexdigest() + "." + self.list[
                len(self.list) - 1]
            self.path = "D:\\nginx-1.15.10\\templates\\"
            self.file.save(self.path + self.file_name)
            # try:
            #     os.remove(self.file_name)
            # except Exception as e:
            #     print(e)
            return {
                'code': 0,
                'path': api_base_url + "/" + self.file_name
            }, 200

        except Exception as e:
            print(e)
            return {"code": -1, "msg": str(e)}, 200
Exemplo n.º 3
0
    def get(self):
        try:
            self.timeClass = Utils.Time()
            self.parser = reqparse.RequestParser()
            self.aiClass = AI.AI()
            self.openid = request.headers['Openid']

            self.restatus = self.aiClass.get_ai_log(self.openid)

            return self.restatus, 200

        except Exception as e:
            print(e)
            return {"code": -1, "data": {"msg": str(e)}}, 500
Exemplo n.º 4
0
Arquivo: Food.py Projeto: jon-son/msdt
 def __init__(self):
     self.mysqlClass = Mysql.MySQL()
     self.timeClass = Utils.Time()
Exemplo n.º 5
0
 def __init__(self):
     self.mysqlClass = Mysql.MySQL()
     self.redis = Redis.Redis()
     self.time = Utils.Time()