I want my Android app to execute a complex website on a local http server directly on the phone.
For that, I implemented nanohttpd. With this library, I can run locally on my phone on a http server some simple html code like this:
public Response serve(IHTTPSession session) {
String msg = "<html><body><h1>Hello server</h1>\n";
Map<String, String> parms = session.getParms();
if (parms.get("username") == null) {
msg += "<form action='?' method='get'>\n <p>Your name: <input type='text' name='username'></p>\n" + "</form>\n";
} else {
msg += "<p>Hello, " + parms.get("username") + "!</p>";
}
return newFixedLengthResponse( msg + "</body></html>\n" );
}
Similar code can be see in the demo app here.
But what I want is to run a full complex website with an index.html file and many other files (namely javascript files). To be more specific, I want to run a WebGL website on a local server on my Android phone.
So, I have all the files of my website in the 'assets' folder of my apk. When the app launches, I copy all the files to the internal storage of the Android phone (to file:///storage/emulated/0/android/data/com.example.mysuperapp/files )
Thus, index.html is located in /files.
How can I do if I want that http://192.168.0.26:8080/index.html runs smoothly the website located at file:///storage/emulated/0/android/data/com.example.mysuperapp/files/index.html ? (meaning that all the javascript files, imports, etc... should work properly)
If nanohttpd is not designed for that, is there any other tool to do that?
Thanks a lot for your help.