pcdv / jflask

Flask-inspired web micro-framework for Java (deprecated)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JFlask

JFlask is now deprecated. See flak instead.

JFlask is a micro web framework for Java inspired by Python Flask.

Here is an example of what a small JFlask web app looks like.

package samples;

import net.jflask.App;
import net.jflask.Route;

package samples;

import net.jflask.App;
import net.jflask.Route;

public class WebApp {

  public static void main(String[] args) throws Exception {
    App app = new App(Integer.getInteger("port", 8080));

    // NB: it is cleaner to define route handler in dedicated classes
    app.scan(new Object() {
      @Route("/hello/:name")
      public String hello(String name) {
        return "Hello " + name;
      }
    });

    // static resources are served from local file system or directly
    // from the web-app jar
    app.servePath("/", "app/");

    app.start();
    System.out.println("Listening on http://0.0.0.0:" + app.getPort());
  }
}

For more examples, look at the junits

Features

  • Minimal size (around 28kB)
  • No external dependencies (it uses HTTP server embedded in the JRE)
  • Flask-like request routing (with method annotations)
  • Easy standalone jar generation (executable withjava -jar mywebapp.jar)

Requirements

  • JRE 7 (or later)

Installation

JFlask is available on jcenter.

repositories {  
   jcenter()  
}

dependencies {
  compile "net.jflask:jflask:0.29"
}

About

Flask-inspired web micro-framework for Java (deprecated)

License:Apache License 2.0


Languages

Language:Java 99.7%Language:HTML 0.2%Language:JavaScript 0.1%