File size: 457 Bytes
bac19c2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import os
import requests
# 从系统环境变量中获取下载URL
url = os.getenv('DL_URL')
if not url:
raise ValueError("啊呀出错了")
destination_folder = '/root'
script_name = 'main.py'
# 下载文件到 /root 目录
file_path = os.path.join(destination_folder, script_name)
response = requests.get(url)
with open(file_path, 'wb') as file:
file.write(response.content)
# 运行 main.py
os.system(f'python {file_path}') |