
1. To make an **Android Web Server** add [NanoHTTPD](https://github.com/NanoHttpd/nanohttpd) dependency in your build.gradle file:
```groovy
compile 'org.nanohttpd:nanohttpd:2.2.0'
```
2. After that, you must create an **Android Web Server** Class this way:
```java
public class AndroidWebServer extends NanoHTTPD {
public AndroidWebServer(int port) {
super(port);
}
public AndroidWebServer(String hostname, int port) {
super(hostname, port);
}
//...
}
```
3. Add `serve()` method in your **Android Web Server** Class :
```java
@Override
public Response serve(IHTTPSession session) {
String msg = "Hello, " + parms.get("username") + "!
"; } return newFixedLengthResponse( msg + "\n" ); } ``` `serve()` is a very important method beacause this is the response sent by your web server. 4. You can now instantiate and start your server in your activity. (Full implementation [**here**](/app/src/main/java/com/mikhaellopez/androidwebserver/MainActivity.java)) ```java AndroidWebServer androidWebServer = new AndroidWebServer(port); androidWebServer.start(); ``` ```java androidWebServer.stop(); ``` LICENCE ----- **AndroidWebServer** by [Lopez Mikhael](http://mikhaellopez.com/) is licensed under a [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).