赞
踩
rainAlgo.uuid = this.algoProject.UUID; trainAlgo.task = this.algoProject.Task; trainAlgo.projectName = this.tb_projectName.Text.Trim(); trainAlgo.epoch = this.tb_epoch.Text.Trim(); trainAlgo.imgsz = this.tb_height.Text.Trim(); trainAlgo.device = this.tb_device.Text.Trim(); trainAlgo.batch = this.tb_batch.Text.Trim(); trainAlgo.weights = this.tb_weights.Text.Trim(); trainAlgo.save_loacal_path = ""; trainAlgo.project = this.tb_SaveDir.Text.Trim(); trainAlgo.data_yaml = this.dataYamlSPath; trainAlgo.algoCategory = this.tb_algoCategory.Text.Trim(); // 2. 发送请求(初始化模型) string url = "http://127.0.0.1:5000/init_algo"; JObject train_param = JObject.FromObject(trainAlgo); // 初始化模型 api.GET_V2(url, train_param);
public void GET_V2(string url, JObject param) { try { // 拼接访问字符串 if (param != null) //有参数的情况下,拼接url { url = url + "?"; foreach (var item in param) { url = url + item.Key + "=" + item.Value + "&"; } url = url.Substring(0, url.Length - 1); } HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;//创建请求 request.Method = "GET";//这里是POST请求,可以改成GET request.ContentType = "application/x-www-form-urlencoded"; request.BeginGetResponse(new AsyncCallback(Compleate), request); } catch { MessageBox.Show("请求失败."); } } public static void Compleate(IAsyncResult asyncResult) { try { HttpWebRequest req = (asyncResult.AsyncState as HttpWebRequest); HttpWebResponse res = req.EndGetResponse(asyncResult) as HttpWebResponse; StreamReader reader = new StreamReader(res.GetResponseStream()); MessageBox.Show(reader.ReadToEnd()); } catch { MessageBox.Show("获取失败."); } }
public static void HttpPost(string Url) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.Method = "POST";//这里是POST请求,可以改成GET request.ContentType = "application/x-www-form-urlencoded"; request.BeginGetResponse(new AsyncCallback(Compleate), request); } catch { MessageBox.Show("请求失败."); } } public static void Compleate(IAsyncResult asyncResult) { try { HttpWebRequest req = (asyncResult.AsyncState as HttpWebRequest); HttpWebResponse res = req.EndGetResponse(asyncResult) as HttpWebResponse; StreamReader reader = new StreamReader(res.GetResponseStream()); MessageBox.Show(reader.ReadToEnd()); } catch { MessageBox.Show("获取失败."); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。