|
|
@@ -16,17 +16,14 @@ config = configparser.ConfigParser()
|
|
|
config_name = "config.ini"
|
|
|
config.read(config_name)
|
|
|
debug = config.get("app", "debug")
|
|
|
-if bool(debug) == False:
|
|
|
- origin = config.get("prod", "origin")
|
|
|
- host = config.get("prod", "host")
|
|
|
- domain = config.get("prod", "domain")
|
|
|
-else:
|
|
|
- origin = config.get("dev", "origin")
|
|
|
- host = config.get("dev", "host")
|
|
|
- domain = config.get("dev", "domain")
|
|
|
+env = config.get("app", "env")
|
|
|
+print("debug====>", debug)
|
|
|
+print("debug====>", debug,123)
|
|
|
+origin = config.get(env, "origin")
|
|
|
+host = config.get(env, "host")
|
|
|
+domain = config.get(env, "domain")
|
|
|
Origin = origin
|
|
|
Host = host
|
|
|
-DOMAIN = domain
|
|
|
|
|
|
|
|
|
class JsonEncoder(json.JSONEncoder):
|
|
|
@@ -66,15 +63,16 @@ class GetOnlineData(object):
|
|
|
|
|
|
def get_key_secret(self):
|
|
|
# 获取抠图剩余次数
|
|
|
- url = "{domain}/api/ai_image/client/get_key_serect".format(domain=DOMAIN)
|
|
|
+ url = "{domain}/api/ai_image/client/get_key_serect".format(domain=domain)
|
|
|
_s = self.s.post(url=url, headers=self.post_headers, timeout=10)
|
|
|
response_data = _s.json()
|
|
|
return response_data["data"]
|
|
|
|
|
|
def get_cutout_image_times(self):
|
|
|
# 获取抠图剩余次数
|
|
|
+ print("domain", domain)
|
|
|
url = "{domain}/api/ai_image/client/search_company_balance".format(
|
|
|
- domain=DOMAIN
|
|
|
+ domain=domain
|
|
|
)
|
|
|
_s = self.s.post(url=url, headers=self.post_headers, timeout=10)
|
|
|
response_data = _s.json()
|
|
|
@@ -85,7 +83,7 @@ class GetOnlineData(object):
|
|
|
|
|
|
def search_progress(self, generate_ids):
|
|
|
# 查进度
|
|
|
- url = "{domain}/api/ai_image/client/search_progress".format(domain=DOMAIN)
|
|
|
+ url = "{domain}/api/ai_image/client/search_progress".format(domain=domain)
|
|
|
data = {"generate_ids": generate_ids}
|
|
|
_s = self.s.post(
|
|
|
url=url, headers=self.post_headers, data=json.dumps(data), timeout=60
|
|
|
@@ -103,7 +101,7 @@ class GetOnlineData(object):
|
|
|
return Image.open(BytesIO(pic))
|
|
|
|
|
|
def remove_background(self, images_url):
|
|
|
- url = "{domain}/api/ai_image/client/remove_background".format(domain=DOMAIN)
|
|
|
+ url = "{domain}/api/ai_image/client/remove_background".format(domain=domain)
|
|
|
data = {"images": images_url}
|
|
|
_s = self.s.post(
|
|
|
url=url, headers=self.post_headers, data=json.dumps(data), timeout=30
|
|
|
@@ -124,7 +122,7 @@ class GetOnlineData(object):
|
|
|
return _menu_dict
|
|
|
|
|
|
url = "{domain}/api/backend/basic/get_current_menu".format(
|
|
|
- domain=DOMAIN,
|
|
|
+ domain=domain,
|
|
|
)
|
|
|
Headers = {
|
|
|
"Authorization": self.token,
|
|
|
@@ -173,7 +171,7 @@ class GetOnlineData(object):
|
|
|
else:
|
|
|
files = [("file", ("1.jpg", buffer, "image/{}".format("JPEG")))]
|
|
|
|
|
|
- url = "{domain}/api/backend/upload".format(domain=DOMAIN)
|
|
|
+ url = "{domain}/api/backend/upload".format(domain=domain)
|
|
|
|
|
|
headers = {
|
|
|
"Authorization": self.token,
|
|
|
@@ -193,7 +191,7 @@ class GetOnlineData(object):
|
|
|
|
|
|
def dispose_point(self, _type):
|
|
|
# 扣分 sub;add为增加分数,每次操作一分
|
|
|
- url = "{domain}/api/ai_image/client/dispose_point".format(domain=DOMAIN)
|
|
|
+ url = "{domain}/api/ai_image/client/dispose_point".format(domain=domain)
|
|
|
data = {"type": _type}
|
|
|
_s = self.s.post(
|
|
|
url=url, headers=self.post_headers, data=json.dumps(data), timeout=10
|
|
|
@@ -203,7 +201,7 @@ class GetOnlineData(object):
|
|
|
|
|
|
def send_message(self, text):
|
|
|
# 发送钉钉消息
|
|
|
- url = "{domain}/api/ai_image/client/send_message".format(domain=DOMAIN)
|
|
|
+ url = "{domain}/api/ai_image/client/send_message".format(domain=domain)
|
|
|
data = {"message": text}
|
|
|
_s = self.s.post(
|
|
|
url=url, headers=self.post_headers, data=json.dumps(data), timeout=10
|