title: How to create nanohttpd server in android?
body: <p>Actually ,I had searched some questions and go to the github. But I'm new ,I cannot understand the example.</p>
  
  <p>I want to create the http server in android so I can access it in PC browser.</p>
  
  <p>I had instance a class extend nanohttpd, but the server just don't work. I don't know why ,my computer and phone are in the same WIFI,uh.....</p>
  
  <pre><code>public class MyHTTPD extends NanoHTTPD {
  
       /**
       * Constructs an HTTP server on given port.
       */
      public MyHTTPD()throws IOException {
          super(8080);
      }
  
  
  @Override
      public Response serve( String uri, Method method,
              Map&lt;String, String&gt; header, Map&lt;String, String&gt; parms,
              Map&lt;String, String&gt; files )
      {
          System.out.println( method + " '222" + uri + "' " );
          String msg = "&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello server&lt;/h1&gt;\n";
          if ( parms.get("username") == null )
              msg +=
                  "&lt;form action='?' method='get'&gt;\n" +
                  "  &lt;p&gt;Your name: &lt;input type='text' name='username'&gt;&lt;/p&gt;\n" +
                  "&lt;/form&gt;\n";
          else
              msg += "&lt;p&gt;Hello, " + parms.get("username") + "!&lt;/p&gt;";
  
          msg += "&lt;/body&gt;&lt;/html&gt;\n";
          return new NanoHTTPD.Response(msg );
      }
  
  
      public static void main( String[] args )
      {
          try
          {
              new MyHTTPD();
          }
          catch( IOException ioe )
          {
              System.err.println( "Couldn't start server:\n" + ioe );
              System.exit( -1 );
          }
          System.out.println( "Listening on port 8080. Hit Enter to stop.\n" );
          try { System.in.read(); } catch( Throwable t ) {
              System.out.println("read error");
          };
      }
  
  }
  </code></pre>