Libraryless. Click here for Pure Java version (1999L/16K/40K).
!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
Began life as a copy of #1000435
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, mrjhfnjfopze, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, tzxuzeklshpk, vouqrxazstgt, xinetxnxrdbb
1 comment(s) hidden. show
Snippet ID: | #1000436 |
Snippet name: | Android/desktop: Web server test using NanoHTTPD on port 8888, shortened |
Eternal ID of this version: | #1000436/1 |
Text MD5: | 9264b382e1fe1fd338468de42d03e17f |
Transpilation MD5: | 0f80b6b671145f094d794e51706dfe49 |
Author: | stefan |
Category: | javax android |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-07 20:50:04 |
Source code size: | 878 bytes / 34 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 936 / 1680 |
Referenced in: | [show references] |