Affichage Page Web
bonjour j'ai un problème j'aimerai que mon site web s'affiche correctement j'ai donc fait une boucle pour faire appel toutes les images .htm. mais le problème est que ma boucle prends en compte uniquement la page index.htm, le style.css et l'image de fond (fond.png). est ce que vous savez pourquoi mes autres images et page ne s'affiche pas merci.
code: [select]
#include <spi.h>
#include <ethernet.h>
#include <sd.h>
// mac address ethernet shield sticker under board
byte mac[] = { 0x90, 0xa2, 0xda, 0x0f, 0x1f, 0xed };
ipaddress ip(169, 254, 73, 50); // ip address, may need change depending on network
ethernetserver server(80); // create server @ port 80
file webfile;
string http_req = ""; // stores received http request
void setup()
{
ethernet.begin(mac, ip); // initialize ethernet device
server.begin(); // start listen clients
serial.begin(9600); // debugging
// initialize sd card
serial.println("initializing sd card...");
if (!sd.begin(4)) {
serial.println("error - sd card initialization failed!");
return; // init failed
}
serial.println("success - sd card initialized.");
// check index.htm file
if (!sd.exists("index.htm")) {
serial.println("error - can't find index.htm file!");
return; // can't find index file
}
serial.println("success - found index.htm file.");
}
void loop()
{
ethernetclient client = server.available(); // try client
if (client) { // got client?
boolean currentlineisblank = true;
while (client.connected()) {
if (client.available()) { // client data available read
char c = client.read(); // read 1 byte (character) client
http_req += c; // save http request character
// print http request character serial monitor
serial.print(c);
// last line of client request blank , ends \n
// respond client after last line received
if (c == '\n' && currentlineisblank) {
// send web page
if ((http_req.indexof("get / ") > -1) ||
(http_req.indexof("get /index.htm") > -1)) {
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println("connnection: close");
client.println();
webfile = sd.open("index.htm"); // open web page file
}
else if (http_req.indexof("get /style.css") > -1) {
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println("connnection: close");
client.println();
webfile = sd.open("style.css"); // open web page file
}
else if (http_req.indexof("get /en_index.htm") > -1) {
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println("connnection: close");
client.println();
webfile = sd.open("en_index.htm"); // open web page file
}
else if (http_req.indexof("get /en_style.css") > -1) {
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println("connnection: close");
client.println();
webfile = sd.open("en_style.css"); // open web page file
}
else if (http_req.indexof("get /fond.png") > -1) {
webfile = sd.open("fond.png");
if (webfile) {
client.println("http/1.1 200 ok");
client.println();
}
}
else if (http_req.indexof("get /logo.png") > -1) {
webfile = sd.open("logo.png");
if (webfile) {
client.println("http/1.1 200 ok");
client.println();
}
}
else if (http_req.indexof("get /en.png") > -1) {
webfile = sd.open("en.png");
if (webfile) {
client.println("http/1.1 200 ok");
client.println();
}
}
else if (http_req.indexof("get /fr.png") > -1) {
webfile = sd.open("fr.png");
if (webfile) {
client.println("http/1.1 200 ok");
client.println();
}
}
if (webfile) {
while(webfile.available()) {
client.write(webfile.read()); // send web page client
}
webfile.close();
}
http_req = ""; // empty string
break;
}
// every line of text received client ends \r\n
if (c == '\n') {
// last character on line of received text
// starting new line next character read
currentlineisblank = true;
}
else if (c != '\r') {
// text character received client
currentlineisblank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give web browser time receive data
client.stop(); // close connection
} // end if (client)
}
j'ai mis toutes les images de mon site sur une seul image (fond.png). maintenant j'ai réussi afficher mes valeurs dans le index.htm mais le problème que j'ai c'est que je n'arrive pas placer c'est valeur l'endroit ou je veux.
j'ai essayé d'utiliser du php avec
# mise à jours
j'ai mis ma température dans <h4>
j'ai essayé d'utiliser du php avec
code: [select]
<?php echo $ftemperature; ?>
mais rien ne s'affiche # mise à jours
j'ai mis ma température dans <h4>
code: [select]
client.print("<h4>");
client.print(" temperature: ");
client.print(weatherdata.ftemperature);
client.print("c (");
client.print(weatherdata.shtemperature);
client.print(")");
client.print("</h4>");
j'ai essayé de modifier dans le css code: [select]
h4 {
font-size:20px;
position:absolute;
color:#5c5f61;
left: 380px;
top: -50px; */
}
mais ma valeur ne change pas de position mais change de couleur et de taille.
Arduino Forum > International > Français (Moderators: jfs, Snootlab) > Affichage Page Web
arduino
Comments
Post a Comment