Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1007972 // Disecting the NanoHTTPD Server

JavaX source code - run with: x30.jar

!747

class MyHTTPD extends NanoHTTPD {
  public MyHTTPD(int port) throws IOException { super(port); }

  public Response serve(String uri, Method method,
      Map<S, S> header, Map<S, S> parms, Map<S, S> files) {
    System.out.println( method + " '222" + uri + "' " );
    String msg = "<html><body><h1>Hello server</h1>\n";
    
    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>";

    msg += "</body></html>\n";
    return newFixedLengthResponse(msg);
  }
}

m {
  static int port = 8888;
  static MyHTTPD server;
  
  p {
    server = new MyHTTPD(port);
    server.start();
  }
}

!include #1000433 // class NanoHTTPD

Author comment

Began life as a copy of #1000436

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xinetxnxrdbb

Comments [hide]

ID Author/Program Comment Date
1321 stefan Hi caramel :-)

If you would like some support for using JavaX, please just contact me at info@ai1.lol. I can e.g. give you server transpilation rights which makes working with JavaX more fun.

Also eventually I will have to think about a system that allows users of JavaX to be unaffected by the very most recent changes I make to the core system. We can do that together if you like.

All the best,
Stefan
2017-04-17 22:33:21

add comment

Snippet ID: #1007972
Snippet name: Disecting the NanoHTTPD Server
Eternal ID of this version: #1007972/1
Text MD5: 9264b382e1fe1fd338468de42d03e17f
Author: caramel
Category: javax android
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-17 22:21:38
Source code size: 878 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 1082 / 1070
Referenced in: [show references]