mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-29 00:10:09 +08:00
zrok share removed from project
This commit is contained in:
parent
0b1efa3044
commit
3116e61020
2
main.py
2
main.py
@ -333,8 +333,6 @@ if __name__ == "__main__":
|
|||||||
app.logger.print_startup_warnings()
|
app.logger.print_startup_warnings()
|
||||||
event_loop.run_until_complete(x)
|
event_loop.run_until_complete(x)
|
||||||
|
|
||||||
threading.Thread(target=py_share.zrok_thread, daemon=True, args=(args.port,)).start()
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logging.info("\nStopped server")
|
logging.info("\nStopped server")
|
||||||
|
|
||||||
|
|||||||
105
notion.py
105
notion.py
@ -1,105 +0,0 @@
|
|||||||
import os
|
|
||||||
from notion_client import Client
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
# 设置你的 Notion API Token 和 数据库 ID
|
|
||||||
NOTION_TOKEN = "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"
|
|
||||||
NOTION_DATABASE_ID = "230de91f217680388daed107820a5dc8"
|
|
||||||
|
|
||||||
if not NOTION_TOKEN or not NOTION_DATABASE_ID:
|
|
||||||
print("请设置 NOTION_TOKEN 和 NOTION_DATABASE_ID 环境变量。")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
# 初始化 Notion 客户端
|
|
||||||
notion = Client(auth=NOTION_TOKEN)
|
|
||||||
|
|
||||||
def get_all_records_from_database():
|
|
||||||
"""
|
|
||||||
从 Notion 数据库获取所有记录的 ID。
|
|
||||||
"""
|
|
||||||
records_id = []
|
|
||||||
has_more = True
|
|
||||||
next_cursor = None
|
|
||||||
|
|
||||||
print(f"正在从数据库 '{NOTION_DATABASE_ID}' 获取记录...")
|
|
||||||
while has_more:
|
|
||||||
try:
|
|
||||||
# 查询数据库
|
|
||||||
# 注意: Notion API 对查询结果有分页限制 (通常每页 100 条)
|
|
||||||
response = notion.databases.query(
|
|
||||||
database_id=NOTION_DATABASE_ID,
|
|
||||||
start_cursor=next_cursor
|
|
||||||
)
|
|
||||||
|
|
||||||
for page in response["results"]:
|
|
||||||
records_id.append(page["id"])
|
|
||||||
|
|
||||||
has_more = response["has_more"]
|
|
||||||
next_cursor = response["next_cursor"]
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取记录失败: {e}")
|
|
||||||
break
|
|
||||||
|
|
||||||
print(f"找到 {len(records_id)} 条记录。")
|
|
||||||
return records_id
|
|
||||||
|
|
||||||
def archive_record(page_id):
|
|
||||||
"""
|
|
||||||
归档(删除)指定的 Notion 页面(记录)。
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
notion.pages.update(
|
|
||||||
page_id=page_id,
|
|
||||||
archived=True
|
|
||||||
)
|
|
||||||
print(f"成功归档页面: {page_id}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"归档页面 {page_id} 失败: {e}")
|
|
||||||
|
|
||||||
def delete_all_records():
|
|
||||||
"""
|
|
||||||
删除数据库中所有现有记录,然后插入新的记录。
|
|
||||||
|
|
||||||
Args:
|
|
||||||
new_record_data (list of dict): 包含要插入的新记录数据的列表,
|
|
||||||
每个字典应包含 'name', 'tags', 'status' 等键。
|
|
||||||
"""
|
|
||||||
print("\n--- 步骤 1: 删除(归档)所有现有记录 ---")
|
|
||||||
record_ids_to_delete = get_all_records_from_database()
|
|
||||||
|
|
||||||
if not record_ids_to_delete:
|
|
||||||
print("数据库中没有需要删除的记录。")
|
|
||||||
else:
|
|
||||||
for page_id in record_ids_to_delete:
|
|
||||||
archive_record(page_id)
|
|
||||||
print("所有现有记录已归档。")
|
|
||||||
|
|
||||||
def add_record_to_notion_database(url):
|
|
||||||
"""
|
|
||||||
向 Notion 数据库插入一条新记录。
|
|
||||||
|
|
||||||
"""
|
|
||||||
current_datetime = datetime.now()
|
|
||||||
formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
|
|
||||||
try:
|
|
||||||
new_page = notion.pages.create(
|
|
||||||
parent={"database_id": NOTION_DATABASE_ID},
|
|
||||||
properties={
|
|
||||||
"更新时间": {
|
|
||||||
"title": [
|
|
||||||
{
|
|
||||||
"text": {"content": formatted_datetime}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"地址": {
|
|
||||||
"url": url # <<--- 传递一个简单的 URL 字符串
|
|
||||||
}
|
|
||||||
# 根据你的数据库结构添加更多属性
|
|
||||||
},
|
|
||||||
)
|
|
||||||
print(f"成功插入记录: {url}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"插入记录失败: {e}")
|
|
||||||
42
py_share.py
42
py_share.py
@ -1,42 +0,0 @@
|
|||||||
import threading
|
|
||||||
|
|
||||||
import notion
|
|
||||||
from pyngrok import ngrok, conf
|
|
||||||
|
|
||||||
# Replace 'YOUR_NGROK_AUTH_TOKEN' with your actual token
|
|
||||||
# This helps avoid connection limits for unauthenticated users.
|
|
||||||
conf.get_default().auth_token = "2mpZeIQCMUw0OBOVtSsfDlhtmBH_2jXryAAHrdL1tLRaaPkSA"
|
|
||||||
|
|
||||||
def ngrok_thread(port):
|
|
||||||
try:
|
|
||||||
# ngrok will try to tunnel to port 5000
|
|
||||||
public_url = ngrok.connect(addr=port)
|
|
||||||
print(f"ngrok tunnel established at: {public_url}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error starting ngrok tunnel: {e}")
|
|
||||||
print("This often happens due to Kaggle's network restrictions.")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from zrok.proxy import ProxyShare
|
|
||||||
import zrok
|
|
||||||
|
|
||||||
def zrok_thread(port):
|
|
||||||
# Load the user's zrok environment from ~/.zrok
|
|
||||||
zrok_env = zrok.environment.root.Load()
|
|
||||||
|
|
||||||
# Create a temporary proxy share (will be cleaned up on exit) 运行时停止的时候自动清理
|
|
||||||
proxy = ProxyShare.create(root=zrok_env, target=f"http://127.0.0.1:{port}") #
|
|
||||||
|
|
||||||
print(f"Public URL: {proxy.endpoints}")
|
|
||||||
for share_url in proxy.endpoints:
|
|
||||||
print(share_url)
|
|
||||||
notion.add_record_to_notion_database(share_url)
|
|
||||||
|
|
||||||
proxy.run()
|
|
||||||
|
|
||||||
|
|
||||||
# threading.Thread(target=ngrok_thread, daemon=True, args=(8188,)).start()
|
|
||||||
# threading.Thread(target=zrok_thread, daemon=True, args=(8188,)).start()
|
|
||||||
# time.sleep(5) # 观察5秒内是否有输出
|
|
||||||
@ -21,7 +21,6 @@ tqdm
|
|||||||
psutil
|
psutil
|
||||||
alembic
|
alembic
|
||||||
SQLAlchemy
|
SQLAlchemy
|
||||||
notion-client
|
|
||||||
|
|
||||||
#non essential dependencies:
|
#non essential dependencies:
|
||||||
kornia>=0.7.1
|
kornia>=0.7.1
|
||||||
|
|||||||
13
script.sh
13
script.sh
@ -93,16 +93,3 @@ cd custom_nodes
|
|||||||
git clone https://github.com/Vander-Bilt/MyHTMLNode.git
|
git clone https://github.com/Vander-Bilt/MyHTMLNode.git
|
||||||
cd /kaggle/ComfyUI
|
cd /kaggle/ComfyUI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pyngrok
|
|
||||||
pip install pyngrok
|
|
||||||
|
|
||||||
# zrok环境准备
|
|
||||||
mkdir -p ~/.zrok
|
|
||||||
cp -r /kaggle/input/zrok-env/. ~/.zrok/
|
|
||||||
|
|
||||||
pip install zrok waitress
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user