Using HTML file in Arduino WiFi shield WebServer

Is there a way to replace multiple client.print("") lines with one line to load and HTML file.

For example, I want to replace the following code with one, or a couple lines that call an HTML file.

client.print(" Click here to turn ON");
client.print("
“);
client.print(” Click here to turn OFF");

Is this possible without an SD card?

I will eventually have many lines of HTML and don’t want to flood the Arduino code with a bunch of HTML.

Yes, you can do that.

If your Ethernet and SD card share a SPI interface you will have to switch the SPI connection as you process each line.

My Arduino web server displays text files on web pages by doing just what you want.

However I still embed my html code within my sketch because I generally want to create dynamic web pages.

Also, you need to be using flash strings F() if your println() statements to save your precious RAM.

Cheers

Catweazle NZ

You can bundle static lines of text in the F() macro like below.

client.print(F(  //start F() macro
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
"<HTML>"
"<HEAD>"
"<meta name='apple-mobile-web-app-capable' content='yes' />"
"<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />"
"<TITLE>JAVA Page</TITLE>"
"</HEAD>"
"<BODY>"
"<H1>JAVA</H1>"
"<hr />"
"
"
"<FORM ACTION='/' method=get >"
"Enter Code: <INPUT TYPE=TEXT NAME='LED' VALUE='' SIZE='25' MAXLENGTH='50'>
"
"
"
"<input type=submit value='5 ON' style=width:100px;height:45px onClick=location.href='/?on8;'><input type=submit value='5 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>
"
"<input type=submit value='6 ON' style=width:100px;height:45px onClick=location.href='/?on8;'><input type=submit value='6 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>
"
"<input type=submit value='7 ON' style=width:100px;height:45px onClick=location.href='/?on8;'><input type=submit value='7 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>
"
"<input type=submit value='8 ON' style=width:100px;height:45px onClick=location.href='/?on8;'><input type=submit value='8 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>
"
"</FORM>"
"</BODY>"
"</HTML>"
));   //end F() macro