一:被控端创建web服务
1.下载flask
pip install flask
2.创建flask app
from flask import Flask
from flask import request
import subprocess
app = Flask(__name__)
@app.route('/run_robot', methods=['POST'])
def run_robot():
# 启用conda robot程序
try:
# run
command = "activate D:\\Anaconda\\env\\python3.9.7 && robot D:\\liuxiaokang_project\\helper\\user_case\\login\\login.robot"
subprocess.run(command, shell=True)
return "robot 程序已启动"
except Exception as e:
return f"启动 robot 程序时发生错误: {str(e)}"
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
3.启用服务(中奖经历:华为笔记本 家庭版win11系统 要把防火墙,华为控制中心,华为安全中心关闭,不然没办法访问端口)
python app.py