Я пытаюсь создать мобильный сайт, и я хочу, чтобы иметь возможность запускать его на моем Arduino UNO для моего проекта класса. У меня возникли проблемы с компоновкой css и javascript для работы на веб-сайте. Когда я запускаю сайт, он показывает только простой HTML-код на сайте. Мне было просто интересно, если я буду об этом правильный путь для того, чтобы добавить их к server.`Как получить файлы CSS/JS на Arduino?
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
// limit the size of the stored received HTTP request
// buffer first part of HTTP request in HTTP_req array (string)
// leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
if (req_index < (REQ_BUF_SZ - 1)) {
HTTP_req[req_index] = c; // save HTTP request character
req_index++;
}
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
// remainder of header follows below, depending on if
// web page or XML page is requested
if (StrContains(HTTP_req, "ajax_inputs")) {
// send rest of HTTP header
client.println("Content-Type: text/xml");
client.println("Connection: keep-alive");
client.println();
SetLEDs();
// send XML file containing input states
XML_response(client);
}
else if (StrContains(HTTP_req, "GET/")|| StrContains(HTTP_req, "GET /index.html"))
{
client.println("Content-Type: text/html");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("index.html"); // open main page
}
else if (StrContains(HTTP_req, "GET /controls.html"))
{
client.println("Content-Type: text/html");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("controls.html");
}
else if (StrContains(HTTP_req, "GET /css/font-awesome.min.css"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("css/font-awesome.min.css");
}
else if (StrContains(HTTP_req, "GET /css/skel.css"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("css/skel.css");
}
else if (StrContains(HTTP_req, "GET /css/style.css"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("css/style.css");
}
else if (StrContains(HTTP_req, "GET /css/style-1000px.css"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("css/style-1000px.css");
}
else if (StrContains(HTTP_req, "GET /css/style-desktop.css"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("css/style-desktop.css");
}
else if (StrContains(HTTP_req, "GET /css/style-mobile.css"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("css/style-mobile.css");
}
else if (StrContains(HTTP_req, "GET /js/init.js"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("js/init.js");
}
else if (StrContains(HTTP_req, "GET /js/jquery.dropotron.min.js"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("js/jquery.dropotron.min.js");
}
else if (StrContains(HTTP_req, "GET /js/jquery.min.js"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("js/jquery.min.js");
}
else if (StrContains(HTTP_req, "GET /js/skel.min.js"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("js/skel.min.js");
}
else if (StrContains(HTTP_req, "GET /js/skel-layers.min.js"))
{
client.println("Content-Type: text/css");
client.println("Connection: keep-alive");
client.println();
webFile = SD.open("js/skel-layers.min.js");
}
//send web page to client
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
}
// display received HTTP request on serial port
Serial.print(HTTP_req);
// reset buffer index and all buffer elements to 0
req_index = 0;
StrClear(HTTP_req, REQ_BUF_SZ);
break;
}
// every line of text received from the client ends with \r\n
if (c == '\n') {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != '\r') {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)`