Hi Everyone! My goal was that my first post would be an answer to a question instead of a question, but i guess i failed ^^
I’ve set up a simple working web server, using Gadgeteer.Networking, but MIME type is set to plain text, and my html is served as plain text. I can not figure out how to set the MIME type and i can not find any example code either… Help please?
Did you get any further with this? I’ve been running into the same limitation on the image side. How about a general purpose RLP that takes data in and spits out bytes formatted correctly back out? I imagine it would be quite a bit faster, especially when working with bitmaps like I am. I just can’t get around how slow it is to serve up a BMP when a JPEG or GIF would be so much smaller.
As for you specific issue, you can rework it to the following,
byte HTML =
Encoding.UTF8.GetBytes("<html><body><p>insert your text here".............
Add whatever you want and close with the following,
and here is an example that would server an html file from the USB drive:
using (FileStream fs = new FileStream(@ "\USB\index.htm", FileMode.Open, FileAccess.Read))
byte buf = new byte[fs.Length];
fs.Read(buf, 0, buf.Length);
responder.Respond(buf, "text/html");//set the MIME Type here
So I ended up just sticking the JS on a sever and linking it in the script URL at the beginning of the response. It’s not self contained, but otherwise works really well. I’ve got HIGHcharts and RGraph running graphical output to my web page with only a few lines of HTML.