I try to run a server from my android app with nanoHTTP. My aim is that everybody connected to the same network as the app can access a html webpage.
So far this is my NanoHttp-server-class:
private class MyHTTPD extends NanoHTTPD {
public MyHTTPD() throws IOException {
super(8080);
}
@Override
public Response serve(IHTTPSession session) {
String msg = "<html><body><h1>Hello server</h1></body></html>\n";
return newFixedLengthResponse(msg);
}
After I start the server from the main activityn, I can see the text "Hello server", when I open ip:port in a browser.
Now my question is, how I can change the html-code from the main activity. I thought about passing the html code to the serve() Method through the IHTTPSession session, but I don't no how to do that and which parameter of session.
So my question is, how can I update the response of my nanoHTTP server or how can I call the serve() Method from the main activity?