Tout ce que j'utilise pour ce morceau c'est ça :
//Content-Type :
P(http200Ok) ="HTTP/1.1 200 OK";
P(httpContentJPG) = "Content-Type: image/jpeg";
P(httpContentText) ="Content-Type: text/plain";
P(httpContentJS) = "Content-Type: application/javascript";
void Tableau(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
if (type == WebServer::POST)
{
// ignore POST data
server.httpFail();
return;
}
/* for a GET or HEAD, send the standard "it's all OK headers" */
//server.httpSuccess("application/javascript");
if (type == WebServer::GET)
{
/* store the HTML in program memory using the P macro */
P(message1) =
"<html><head><title >Simulateur </title></head>"
"<body style=\"text-align:left;\">"
"<div style=\"font-size:200%;font-weight:bold; border: 2px black solid;\">";
P(message2) =
"<span style=\"text-indent:50%;margin-left:150px;margin-top:25px;\">Simulation thermique</span></div>"
"<center>";
P(message3) = "</center>";
P(messageRgraph) = "<script src=\"/RGraph.common.core.js\"></script>";
P(messageRgraph2) ="<script src=\"/RGraph.line.js\"></script>" ;
P(message4) =
"<canvas id=\"myCanvasTag\" width=\"600\" height=\"200\">[No canvas support]</canvas>"
"<script>"
"data = [78,16,26,23,25,51,34,64,84,84];"
"line = new RGraph.Line(\"myCanvasTag\", data);"
"line.Set(\"chart.labels\", [\"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\"]);"
"line.Draw();"
"</script>"
"</body></html>";
server.printP(message1);
server.printP(messageImage);
server.printP(message2);
loadTable(server , "test.csv");
server.printP(message3);
server.printP(messageRgraph);
server.printP(messageRgraph2);
server.printP(message4);
}
}
void jscript(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
loadGraph(server,"RGraph.line.js");
}
void jscript2(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
loadGraph(server,"RGraph.common.core.js");
}
void loadGraph(WebServer &server , char* fichier ){
server.printP(http200Ok);
server.println();
server.printP(httpContentJS);
server.println();
server.println();
Fgraph = SD.open(fichier, FILE_READ);
int c ;
while((c = Fgraph.read()) >= 0){
server.print((char)c);
}
Fgraph.close();
}
void loadTable(WebServer &server , char* table ){
Ftable = SD.open(table, FILE_READ);
int c ;
while((c = Ftable.read()) >= 0){
server.print((char)c);
}
Ftable.close();
}
//setup : webserver.addCommand("test.csv", &Tableau);