Skip to content

Commit

Permalink
集成了正则表达式、字符串替换功能
Browse files Browse the repository at this point in the history
  • Loading branch information
AragonSnow committed May 31, 2020
1 parent ed3d4b6 commit 4833ee6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/Build Image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
publish: true
imageName: asdaragon/qiandao # dockerid/imageName
platform: linux/arm64,linux/amd64 # 你准备构建的镜像平台
tag: 20200526,latest
tag: 20200531,latest
dockerHubUser: ${{ secrets.DOCKER_USERNAME }} # docker hub userid 在setting创建secrets name=DOCKER_USERNAME value=dockerid
dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }} # docker hub password,在setting创建secrets name=DOCKER_PASSWORD value=dockerpassword
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ docker部署命令:``` docker run -d --name qiandao -p 12345:80 -v $(pwd)/qian
## 2020.5.31 更新
1. 修复定时 ‘day out of month’ 的BUG
2. 取消定时界面的今日运行选项,自动判断当前时间是今天还是第二天
3. 集成了时间戳获取、unicode转换、url转换功能(By [gxitm](https://github.com/gxitm))
4. 集成了正则表达式、字符串替换功能。

## 2020.5.30 更新
1. 修改 任务失败时 推送的消息内容为 任务日志;
Expand Down
38 changes: 38 additions & 0 deletions web/handlers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,48 @@ def get(self):
self.set_header('Content-Type', 'application/json; charset=UTF-8')
self.write(json.dumps(Rtv, ensure_ascii=False, indent=4))

class UtilRegexHandler(BaseHandler):
@gen.coroutine
def get(self):
Rtv = {}
try:
data = self.get_argument("data", "")
p = self.get_argument("p", "")
temp = {}
ds = re.findall(p, data, re.IGNORECASE)
for cnt in range (0, len(ds)):
temp[cnt+1] = ds[cnt]
Rtv[u"数据"] = temp
Rtv[u"状态"] = "OK"
except Exception as e:
Rtv[u"状态"] = str(e)

self.set_header('Content-Type', 'application/json; charset=UTF-8')
self.write(json.dumps(Rtv, ensure_ascii=False, indent=4))

class UtilStrReplaceHandler(BaseHandler):
@gen.coroutine
def get(self):
Rtv = {}
try:
s = self.get_argument("s", "")
p = self.get_argument("p", "")
t = self.get_argument("t", "")
Rtv[u"原始字符串"] = s
Rtv[u"处理后字符串"] = re.sub(p, t, s)
Rtv[u"状态"] = "OK"
except Exception as e:
Rtv["状态"] = str(e)

self.set_header('Content-Type', 'application/json; charset=UTF-8')
self.write(json.dumps(Rtv, ensure_ascii=False, indent=4))


handlers = [
('/util/delay/(\d+)', UtilDelayHandler),
('/util/timestamp', TimeStampHandler),
('/util/unicode', UniCodeHandler),
('/util/urldecode', UrlDecodeHandler),
('/util/regex', UtilRegexHandler),
('/util/string/replace', UtilStrReplaceHandler),
]

0 comments on commit 4833ee6

Please sign in to comment.