代码拉取完成,页面将自动刷新
同步操作将从 kerlomz/captcha_platform 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Author: kerlomz <kerlomz@gmail.com>
from enum import Enum, unique
@unique
class ModelScene(Enum):
"""模型场景枚举"""
Classification = 'Classification'
@unique
class ModelField(Enum):
"""模型类别枚举"""
Image = 'Image'
Text = 'Text'
class SystemConfig:
split_flag = b'\x99\x99\x99\x00\xff\xff\xff\x00\x99\x99\x99'
default_route = [
{
"Class": "AuthHandler",
"Route": "/captcha/auth/v2"
},
{
"Class": "NoAuthHandler",
"Route": "/captcha/v1"
},
{
"Class": "SimpleHandler",
"Route": "/captcha/v3"
},
{
"Class": "HeartBeatHandler",
"Route": "/check_backend_active.html"
},
{
"Class": "HeartBeatHandler",
"Route": "/verification"
},
{
"Class": "HeartBeatHandler",
"Route": "/"
},
{
"Class": "ServiceHandler",
"Route": "/service/info"
},
{
"Class": "FileHandler",
"Route": "/service/logs/(.*)",
"Param": {"path": "logs"}
},
{
"Class": "BaseHandler",
"Route": ".*"
}
]
default_config = {
"System": {
"DefaultModel": "default",
"SplitFlag": b'\x99\x99\x99\x00\xff\xff999999.........99999\xff\x00\x99\x99\x99',
"SavePath": "",
"RequestCountInterval": 86400,
"GlobalRequestCountInterval": 86400,
"RequestLimit": -1,
"GlobalRequestLimit": -1,
"WithoutLogger": False,
"RequestSizeLimit": {},
"DefaultPort": 19952,
"IllegalTimeMessage": "The maximum number of requests has been exceeded.",
"ExceededMessage": "Illegal access time, please request in open hours.",
"BlacklistTriggerTimes": -1,
"Whitelist": False,
"ErrorMessage": {
400: "Bad Request",
401: "Unicode Decode Error",
403: "Forbidden",
404: "404 Not Found",
405: "Method Not Allowed",
500: "Internal Server Error"
}
},
"RouteMap": default_route,
"Security": {
"AccessKey": "",
"SecretKey": ""
},
"RequestDef": {
"InputData": "image",
"ModelName": "model_name",
},
"ResponseDef": {
"Message": "message",
"StatusCode": "code",
"StatusBool": "success",
"Uid": "uid",
}
}
class ServerType(str):
FLASK = 19951
TORNADO = 19952
SANIC = 19953
class Response:
def __init__(self, def_map: dict):
# SIGN
self.INVALID_PUBLIC_PARAMS = dict(Message='Invalid Public Params', StatusCode=400001, StatusBool=False)
self.UNKNOWN_SERVER_ERROR = dict(Message='Unknown Server Error', StatusCode=400002, StatusBool=False)
self.INVALID_TIMESTAMP = dict(Message='Invalid Timestamp', StatusCode=400004, StatusBool=False)
self.INVALID_ACCESS_KEY = dict(Message='Invalid Access Key', StatusCode=400005, StatusBool=False)
self.INVALID_QUERY_STRING = dict(Message='Invalid Query String', StatusCode=400006, StatusBool=False)
# SERVER
self.SUCCESS = dict(Message=None, StatusCode=000000, StatusBool=True)
self.INVALID_IMAGE_FORMAT = dict(Message='Invalid Image Format', StatusCode=500001, StatusBool=False)
self.INVALID_BASE64_STRING = dict(Message='Invalid Base64 String', StatusCode=500002, StatusBool=False)
self.IMAGE_DAMAGE = dict(Message='Image Damage', StatusCode=500003, StatusBool=False)
self.IMAGE_SIZE_NOT_MATCH_GRAPH = dict(Message='Image Size Not Match Graph Value', StatusCode=500004, StatusBool=False)
self.INVALID_PUBLIC_PARAMS = self.parse(self.INVALID_PUBLIC_PARAMS, def_map)
self.UNKNOWN_SERVER_ERROR = self.parse(self.UNKNOWN_SERVER_ERROR, def_map)
self.INVALID_TIMESTAMP = self.parse(self.INVALID_TIMESTAMP, def_map)
self.INVALID_ACCESS_KEY = self.parse(self.INVALID_ACCESS_KEY, def_map)
self.INVALID_QUERY_STRING = self.parse(self.INVALID_QUERY_STRING, def_map)
self.SUCCESS = self.parse(self.SUCCESS, def_map)
self.INVALID_IMAGE_FORMAT = self.parse(self.INVALID_IMAGE_FORMAT, def_map)
self.INVALID_BASE64_STRING = self.parse(self.INVALID_BASE64_STRING, def_map)
self.IMAGE_DAMAGE = self.parse(self.IMAGE_DAMAGE, def_map)
self.IMAGE_SIZE_NOT_MATCH_GRAPH = self.parse(self.IMAGE_SIZE_NOT_MATCH_GRAPH, def_map)
def find_message(self, _code):
e = [value for value in vars(self).values()]
_t = [i['message'] for i in e if i['code'] == _code]
return _t[0] if _t else None
def find(self, _code):
e = [value for value in vars(self).values()]
_t = [i for i in e if i['code'] == _code]
return _t[0] if _t else None
def all_code(self):
return [i['message'] for i in [value for value in vars(self).values()]]
@staticmethod
def parse(src: dict, target_map: dict):
return {target_map[k]: v for k, v in src.items()}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。