PROBLEM : I\'m using NanoHTTPD . It\'s working great but it\'s not serving .js files, images and others.
DETAILED EXPLANATION : i
in my serve()
method it looks like this:
@Override
public Response serve(String uri, String method, Properties header, Properties parms, Properties files) {
Log.d(TAG,"SERVE :: URI "+uri);
final StringBuilder buf = new StringBuilder();
for (Entry
There is some not so clean solution with mime types. Validation should be done with something like this Getting A File's Mime Type In Java, I my simple project I am just checking few kinds of mime.
Reference mime types are static fields in NanoHTTPD class:
/**
* Common mime types for dynamic content
*/
public static final String
MIME_PLAINTEXT = "text/plain",
MIME_HTML = "text/html",
MIME_JS = "application/javascript",
MIME_CSS = "text/css",
MIME_PNG = "image/png",
MIME_DEFAULT_BINARY = "application/octet-stream",
MIME_XML = "text/xml";
With this implementation I was able to read files from assets as well as from external memory.