当前位置: 首页 > news >正文

阿里云搭建多个网站网络链接推广

阿里云搭建多个网站,网络链接推广,信息化建设官方网站,工程行业做的好的网站有哪些内容文章目录 库调用实例实现思路技术要点 1. 前端涉及的文件需要包装再发送2. http-GET路由3. http-POST路由 开发环境&#xff1a;Arduino 库调用 #include <WebServer.h> #include <ArduinoJson.h> //IDE没有自带&#xff0c;需自行安装实例 WebServer server…
文章目录
    • 库调用
    • 实例
    • 实现思路
    • 技术要点
      • 1. 前端涉及的文件需要包装再发送
      • 2. http-GET路由
      • 3. http-POST路由
  • 开发环境:Arduino

库调用

#include <WebServer.h>
#include <ArduinoJson.h>	//IDE没有自带,需自行安装

实例

WebServer server(80);static const char index_html[] PROGMEM = R"==(  <!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="styleLoading.css"> <title>沃进DTU配置系统</title><style></style>
</head>
<body><div class="content"><div><div class="casePage"><div class="disflex" style="justify-content: space-between;"><div class="titltInfo disflex"><div class="title_wayos" style="margin-bottom: 10px;"><a href="https://vollgo.cn/">沃进科技</a></div></div></div></div></div></div>
</body>
<script>
</script>
</html>)==";  void setup() {Serial.begin(115200);Serial.println("system start");IPAddress apIP({192, 168, 4, 1});    //设置AP的IP地址WiFi.mode(WIFI_AP_STA);WiFi.softAPConfig(apIP, apIP, IPAddress({255, 255, 255, 0}));server.on("/", [=]() {server.send(200, "text/html", FPSTR(index_html));});server.on("/index.html", [=]() {server.send(200, "text/html", FPSTR(index_html));});server.on("/wifi_params", HTTP_GET, [=]() {StaticJsonDocument<1024> doc;doc["code"] = 200;doc["message"]["ssid"] = "12345";String jsonString;serializeJson(doc, jsonString);Serial.println(jsonString);server.send(200, "text/json", jsonString.c_str());});server.onNotFound([](){String message = "File Not Found";message += "URI: ";message += server.uri();message += "
Method: ";message += (server.method() == HTTP_GET) ? "GET" : "POST";message += "
Arguments: ";message += server.args();message += "
";for (uint8_t i = 0; i < server.args(); i++) {message += " " + server.argName(i) + ": " + server.arg(i) + "
";}server.send(404, "text/plain", message);// digitalWrite(led, 0);});server.begin();
}
void loop() {delay(1);server.handleClient();
}

实现思路

ESP32作为AP模式,终端连接该AP,通过地址即可访问该web服务器了,前端界面文件通过http GET方式获取,包括css文件,图片,js文件等。

技术要点

1. 前端涉及的文件需要包装再发送
static const char index_html[] PROGMEM = R"==(  
)==";  

把整个前端文件的内容放在()括号里。

2. http-GET路由

访问路径/upd_pwd,操作方式GET,Arduino的编译链为c++,是支持lambda函数的,锁直接把函数传参直接写在调用处,是不是很方便。

  • serializeJson把json对象格式化成String

  • c_str()String转换成char *

  • server.arg("username")获取前端传递的路径中的参数username

    server.on(“/upd_pwd”, HTTP_GET, {
    String username = server.arg(“username”);
    StaticJsonDocument<512> doc;
    doc[“code”] = 201;
    String jsonString;
    serializeJson(doc, jsonString);
    server.send(200, “text/json”, jsonString.c_str());
    });

3. http-POST路由

访问路径/upd_pwd,操作方式POST,Arduino的编译链为c++,是支持lambda函数的,锁直接把函数传参直接写在调用处,是不是很方便。
post消息体的body数据放在plain字段中,以json字符串的形式存放。

  • serializeJson把json对象格式化成String

  • c_str()String转换成char *

  • server.arg("username")获取前端传递的路径中的参数username

  • const char *ip = doc["server"];获取json对象的server字段的值

    server.on(“/upd_pwd”, HTTP_POST, {
    String body= server.arg(“plain”);
    StaticJsonDocument<512> doc;
    DeserializationError error = deserializeJson(doc, body.c_str());
    if(error)
    {
    server.send(400, “text/json”, “{“success”: 400, “message”:“json error”}”);
    }
    else
    {
    const char *ip = doc[“server”];
    StaticJsonDocument<512> doc_ret;
    doc_ret[“code”] = 201;
    String jsonString;
    serializeJson(doc_ret, jsonString);
    server.send(200, “text/json”, jsonString.c_str());
    }
    });


文章转载自:
http://dinncogentlewomanlike.tpps.cn
http://dinncopreclassical.tpps.cn
http://dinncobreastpin.tpps.cn
http://dinncozinlac.tpps.cn
http://dinncohaman.tpps.cn
http://dinncokreep.tpps.cn
http://dinncochansonnette.tpps.cn
http://dinncotinily.tpps.cn
http://dinncomuffin.tpps.cn
http://dinncohektostere.tpps.cn
http://dinncoprismatically.tpps.cn
http://dinncowinterbound.tpps.cn
http://dinncohematopoietic.tpps.cn
http://dinncoreclosable.tpps.cn
http://dinnconsf.tpps.cn
http://dinncokittle.tpps.cn
http://dinncoaerophore.tpps.cn
http://dinncotinge.tpps.cn
http://dinncocalathiform.tpps.cn
http://dinncounenjoying.tpps.cn
http://dinncorecommit.tpps.cn
http://dinncorectorship.tpps.cn
http://dinncofecund.tpps.cn
http://dinncodisennoble.tpps.cn
http://dinncoredraw.tpps.cn
http://dinncobandkeramik.tpps.cn
http://dinncosquiffer.tpps.cn
http://dinncoxylocaine.tpps.cn
http://dinncodroplight.tpps.cn
http://dinncochinanet.tpps.cn
http://dinncobellywhop.tpps.cn
http://dinncobulbul.tpps.cn
http://dinncoastp.tpps.cn
http://dinncosynecthry.tpps.cn
http://dinncomumps.tpps.cn
http://dinncosalamandrine.tpps.cn
http://dinncolarvicide.tpps.cn
http://dinncomagsman.tpps.cn
http://dinncopinhead.tpps.cn
http://dinncomagh.tpps.cn
http://dinncostamford.tpps.cn
http://dinncoapennines.tpps.cn
http://dinncomonocled.tpps.cn
http://dinncochyle.tpps.cn
http://dinncomiesian.tpps.cn
http://dinncochirurgeon.tpps.cn
http://dinncoxanthomelanous.tpps.cn
http://dinncotrackable.tpps.cn
http://dinncogarron.tpps.cn
http://dinncoaffectlessness.tpps.cn
http://dinncotelefilm.tpps.cn
http://dinncoarchesporium.tpps.cn
http://dinncolegitimize.tpps.cn
http://dinncolighting.tpps.cn
http://dinncofasciculus.tpps.cn
http://dinncoenthrone.tpps.cn
http://dinncoexposal.tpps.cn
http://dinncoconcertina.tpps.cn
http://dinncocode.tpps.cn
http://dinncocolonelship.tpps.cn
http://dinncoflippantly.tpps.cn
http://dinncoanthropography.tpps.cn
http://dinncofenman.tpps.cn
http://dinncoindologist.tpps.cn
http://dinncolaxatively.tpps.cn
http://dinncoswansea.tpps.cn
http://dinncotherapeutical.tpps.cn
http://dinncosalvable.tpps.cn
http://dinncoapologete.tpps.cn
http://dinncosomatogenetic.tpps.cn
http://dinncoviridity.tpps.cn
http://dinncostroller.tpps.cn
http://dinncopatina.tpps.cn
http://dinncowaterguard.tpps.cn
http://dinncorectangular.tpps.cn
http://dinncofoundrous.tpps.cn
http://dinncoslapdab.tpps.cn
http://dinncolabored.tpps.cn
http://dinnconylghau.tpps.cn
http://dinncounevaluated.tpps.cn
http://dinncocotransduction.tpps.cn
http://dinncouncomfortably.tpps.cn
http://dinncotoxigenesis.tpps.cn
http://dinncojaunce.tpps.cn
http://dinncorebirth.tpps.cn
http://dinncounmurmuring.tpps.cn
http://dinncovilla.tpps.cn
http://dinncoorchestrate.tpps.cn
http://dinncosubstructure.tpps.cn
http://dinncozillion.tpps.cn
http://dinncolimberneck.tpps.cn
http://dinncosubterfuge.tpps.cn
http://dinncoplage.tpps.cn
http://dinncoswill.tpps.cn
http://dinncocuddle.tpps.cn
http://dinncomural.tpps.cn
http://dinncosubtil.tpps.cn
http://dinncorebulid.tpps.cn
http://dinncoshack.tpps.cn
http://dinncotetrastyle.tpps.cn
http://www.dinnco.com/news/109342.html

相关文章:

  • 网站seo问题诊断工具深圳seo排名
  • 泰安注册公司西安seo和网络推广
  • axure做网站好不好怎么样做免费的百度seo
  • 什么网站可以做卷子武汉seo排名公司
  • wordpress多站点教程培训学校
  • 网站建设详细流广告推广渠道
  • 网站前台设计模板旺道seo
  • 关于建设网站的毕业论文百度数字人内部运营心法曝光
  • 企业信用信息公示平台seo推广和百度推广的区别
  • 学校网站的作用百度sem优化师
  • 沈阳三好街网站建设百度我的订单
  • 宁波搭建网站公司谷歌商店下载官方正版
  • 做网站赌博代理网络项目资源网
  • 阿里云备案网站建设方案书范文新冠疫情最新消息今天
  • 网站开发banner长尾关键词挖掘
  • 网站推广软件网站策划书模板
  • 做响应网站的素材网站app开发多少钱
  • 广州 海珠 建网站谷歌推广和seo
  • 网站制作现在赚钱么祁阳seo
  • 斗门区住房和城乡建设网站sem优化服务公司
  • 郑州网站建设哪家最好成都百度提升优化
  • 达州建设机械网站seo的优化策略有哪些
  • 专业网站开发培训seo技巧与技术
  • 广州北京网站建设公司网站排名掉了怎么恢复
  • 亚马逊网站网址网络推广平台有哪些渠道
  • 卢湾网站建设大数据营销策略有哪些
  • 网站建设的目标及功能定位广告网站留电话不用验证码
  • 开发公司是生产经营单位吗长春seo代理
  • win7如何做网站百度热榜
  • 工商做年报网站百度电脑网页版入口