添加获取CNB网址的工具函数,更新主程序以打印运行网址,新增requirements.txt文件,优化前端页面布局和样式,增加移动端菜单功能。
This commit is contained in:
22
utils/tools.py
Normal file
22
utils/tools.py
Normal file
@ -0,0 +1,22 @@
|
||||
import requests
|
||||
import time
|
||||
import re
|
||||
|
||||
s = requests.Session()
|
||||
|
||||
def get_cnb_weburl(port):
|
||||
s.headers= {"Authorization": "2hk178fffIx8tdXLD9YjYJot0gA"}
|
||||
|
||||
res = s.get("https://api.cnb.cool/workspace/list?branch=main&status=running").json()
|
||||
info = res["list"][0]
|
||||
urlinfo = s.get(f"https://api.cnb.cool/{info['slug']}/-/workspace/detail/{info['sn']}").json()
|
||||
|
||||
#re提取cnb-id
|
||||
pattern = r'cnb-[a-z0-9]+-[a-z0-9]+-\d+'
|
||||
match = re.search(pattern, urlinfo["webide"])
|
||||
if match:
|
||||
cnb_id = match.group(0)
|
||||
else:
|
||||
cnb_id = None
|
||||
|
||||
return f"https://{cnb_id}-{port}.cnb.run/"
|
Reference in New Issue
Block a user