这是我第一次尝试这样做。我配置了html文件,该文件已投放。我想使用内部或外部CSS为HTML表单提供样式,但是我可以。但是,我使用了我没有管理的其他教程。我有一个主目录和index.h,style.css和main.ino文件。这是我的代码。谁能告诉我正确的密码是什么?
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include "index.h"
//#include "style.h"
//SSID and Password to your ESP Access Point
const char* cssfile = "style.css";
const char* ssid = "ESPWebServer";
const char* password = "12345678";
ESP8266WebServer server(80); //Server on port 80
//==============================================================
// This rutine is exicuted when you open its IP in browser
//==============================================================
String s = MAIN_page;
//String sx = MAIN_STYLE;
void handleRoot() {
server.send(200, "text/html", s);
server.send(800, "text/css", "");
}
//===============================================================
// SETUP
//===============================================================
void setup(void){
Serial.begin(9600);
Serial.println("");
WiFi.mode(WIFI_AP); //Only Access point
WiFi.softAP(ssid); //Start HOTspot removing password will disable security
//delay(4000);
IPAddress myIP = WiFi.softAPIP(); //Get IP address
Serial.print("HotSpt IP:");
Serial.println(myIP);
server.on("/", handleRoot); //Which routine to handle at root location
server.begin(); //Start server
Serial.println("HTTP server started");
}
//===============================================================
// LOOP
//===============================================================
void loop(void){
server.handleClient(); //Handle client requests
}
bool loadFromSpiffs(String path){
String dataType = "text/plain";
if(path.endsWith("/")) path += "index.htm";
if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
else if(path.endsWith(".html")) dataType = "text/html";
else if(path.endsWith(".css")) dataType = "text/css";
return true;
}