添加获取CNB网址的工具函数,更新主程序以打印运行网址,新增requirements.txt文件,优化前端页面布局和样式,增加移动端菜单功能。

This commit is contained in:
dockermen
2025-04-09 13:04:29 +08:00
parent c6034b8154
commit 7b482b1ef0
5 changed files with 170 additions and 23 deletions

22
utils/tools.py Normal file
View 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/"