Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.
/ PicoHTTPd Public archive

Minimal Embeddable Non-Blocking Java HTTP Server (Android compatible!)

License

Notifications You must be signed in to change notification settings

kasra-sh/PicoHTTPd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PicoHTTPd

Minimal Embeddable NIO HTTP Server

Import :

Include these in your project's build.gradle file

repositories {
	...
	maven { url 'https://jitpack.io' }
}
dependencies {
	...
	compile 'com.github.kasra-sh:picohttpd:0.8.9'
}

Usage :

// Use default config
Pico pico = Pico.getDefault();

// or custom config
pico = Pico.get().setExecutor(Executors.newWorkStealingPool(4));
// or
pico = Pico.get().setExecutor(new ForkJoinPool(4));

// Set handler
pico.setHandler(new HTTPHandler() {
    @Override
    public void handleRequest(Request r, ResponseWriter w) {
        // ResponseWriter accepts Response/byte[] or an InputStream with a byte-array as header
        w.write(Response.makeText(200,"Welcome to NanoServer!\n".getBytes()));
    }
});

// Listen for connections on port 8000
pico.start(8000);

TODO :

  • WebSocket support.

About

Minimal Embeddable Non-Blocking Java HTTP Server (Android compatible!)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published