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

16
LINES

< > BotCompany Repo | #1035558 // serveHttpFromWebServable

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (12597L/76K).

1  
// function: func(S uri, SS params) -> NanoHTTPD.Response or string
2  
static MyHTTPD serveHttpFromWebServable(int port, WebServable webServable) ctex {
3  
  assertNotNull(+webServable);
4  
  
5  
  MyHTTPD server = new(port);
6  
  server.serveFunction = func(S uri, SS params) {
7  
    var session = nanoHTTPDCurrentSession();
8  
    var req = new WebRequest(session, uri, params);
9  
    ret webServable.html(req);
10  
  };
11  
  
12  
  server.start();
13  
  print("HTTP port " + port + " open exposing " + webServable);
14  
  
15  
  ret server;
16  
}

Author comment

Began life as a copy of #1023279

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035558
Snippet name: serveHttpFromWebServable
Eternal ID of this version: #1035558/3
Text MD5: 452e55b924bf33f1ce36c07e3e03d602
Transpilation MD5: b24c01a7345d3fc8359bf85e709d26ea
Author: stefan
Category: javax / http
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-16 19:23:09
Source code size: 515 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 140 / 206
Version history: 2 change(s)
Referenced in: [show references]