ESP32 做Web服务器 http Server步骤
资料不多。多是国外网站的。
百度搜基本出来的是这个网站https://www.dfrobot.com/blog-922.html
出来的代码是:
#include <WiFi.h>
#include <FS.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
const char* ssid = "yourNetworkName";
const char* password = "yourNetworkPassword";
AsyncWebServer server(80);
void setup(){
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println(WiFi.localIP());
server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/html", "<p>This is HTML!</p>");
});
server.begin();
}
void loop(){
}
发愁:这个库在哪里?我怎么运行?于是我找到了这里:
https://github.com/me-no-dev/ESPAsyncWebServer
里面使用ESPAsyncWebServer的步骤
如下:
1 安装:PlatformIO IDE
这里有详细教材:https://blog.csdn.net/baimei4833953/article/details/78771611/
2 创建新的工程:"PlatformIO Home > New Project"
http://docs.platformio.org/en/latest/ide/vscode.html
3 修改配置文件
Add "ESP Async WebServer" to project using Project Configuration File platformio.ini and lib_deps option:
#include <WiFi.h>
#include <FS.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h> const char *ssid = "MyESP32AP";
const char *password = "testpassword"; AsyncWebServer server(80); void setup(){
Serial.begin(115200); WiFi.softAP(ssid, password); Serial.println();
Serial.print("IP address: ");
Serial.println(WiFi.softAPIP()); server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/plain", "Hello World");
}); server.begin();
} void loop(){}
编译运行下载,搞定。。。。
ESP32 做Web服务器 http Server步骤的更多相关文章
- Nginx是什么,有什么优点?为什么选择Nginx做web服务器软件?(经典经典)
1.基础知识 代理服务器: 一般是指局域网内部的机器通过代理服务器发送请求到互联网上的服务器,代理服务器一般作用在客户端.应用比如:GoAgent,FQ神器. 一个完整的代理请求过程为:客 ...
- Nginx做web服务器反向代理
实验目的 通过nginx实现反向代理的功能,类似apache反向代理和haproxy反向代理 工作中用nginx做反向代理和负载均衡的也越来越多了 有些公司从web服务器到反向代理,都使用nginx. ...
- 死磕nginx系列--nginx服务器做web服务器
nginx 做静态服务器 HTML页面如下 <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- node - web 服务器 、server 服务器
node 作为服务端 - 基本使用 1. web 服务器 web.html <!DOCTYPE html> <html> <head> <meta chars ...
- 什么是 Web 服务器(server)
首先我们来了解什么是服务器(server) Web服务器一般指网站服务器,是指驻留于因特网上某种类型计算机的程序,可以向浏览器等Web客户端提供文档,[1]也可以放置网站文件,让全世界浏览:可以放置数 ...
- 树莓派做web服务器(nginx、Apache)
一想到Linux Web服务器,我们首先想到的是: Apache + MySql + Php. Apache:是世界使用排名第一的Web服务器软件. 可以运行在几乎所有广泛使用的计算机平台上,由于其跨 ...
- 基于corosync+pacemaker+drbd+LNMP做web服务器的高可用集群
实验系统:CentOS 6.6_x86_64 实验前提: 1)提前准备好编译环境,防火墙和selinux都关闭: 2)本配置共有两个测试节点,分别coro1和coro2,对应的IP地址分别为192.1 ...
- 利器: 用Siege做Web服务器压测
用「Web压测」关键词检索,能找到好多进行压测的工具,比如ab.Http_load.Webbench.Siege这些,不过今天并不是要对这些工具做对比,毕竟我们只是想得到一个结果.本文主要介绍Sieg ...
- 解决Vue用Nginx做web服务器报错favicon.ico 404 (Not Found)的问题
有多种解决方案 1.vue静态资源 vue中为网页增加favicon的最便捷的方式为使用link标签 <link rel="shortcut icon" type=" ...
随机推荐
- 学习Linux的软件管理、进程管理
一.软件管理 1.使用yum管理软件安装包 1.1什么是yum Yum (全称为:Yellow dog Updater, Modified) 由Duke University团队,修改Yellow D ...
- SQLI DUMB SERIES-17
(1)无论怎么输入username,都没有回显.尝试改变password的输入.找到了闭合方式:单引号 (2)报错注入: 爆库名 admin&passwd=admin' and extract ...
- angular6 导出json数据到excal表
1 首先使用npm下载插件依赖的安装包 npm install file-saver --save npm install xlsx --save 2 引入项目中的ts文件中 impo ...
- 最基础的 swift 语言
import Foundation //打印函数 print("Hello, World!") //不用加分号, 字符串就是"", 不用加@ print(&qu ...
- 锋利的jQuery初学(2)
js与jq事件处理程序区别: 1,事件源: document.getElementById('id'); $("#id") 2,事件: document.getElem ...
- jquery库的cookie用法
一个完整设置与读取cookie的页面代码: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...
- web框架---django
15:31:14一.web框架1.框架:即framework,特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以帮你快速开发特定的系统,简单地说,就是你用别人搭建好的舞台来做表演. ...
- htop的安装和使用
1.Ubuntu16.04中htop安装很简单 sudo apt-get install htop 2.htop的使用,直接以普通用户输入htop命令即可执行 关于其基本介绍和使用方式在见下 http ...
- ssm项目整合shiro
pom.xml <properties> <shiro.version>1.2.2</shiro.version> </properties> < ...
- vue使用axios 时 后台接收不到数据
后台用django 时,默认接收的数据格式为formdata ,前端如果传了其他格式会出现后台收不到参数的情况. 前端参数转 fromdata 代码如下 let formData = new Form ...