| 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}') |