Giter Site home page Giter Site logo

hello-1's Introduction

#hello

This is blade framework of an initial project, running is very simple, experience the charm of it!

/**
 * Hello Blade!
 */
public class App extends Bootstrap {

	@Override
	public void init() {}
	
	public static void main(String[] args) throws Exception {
		Blade blade = Blade.me();
		
		/**
		 * JDK1.6
		 */
		blade.get("/", new RouteHandler() {
			public void handle(Request request, Response response) {
				response.html("<h1>Hello Blade!</h1>");
			}
		});
		
		// java8
		blade.get("/hello", (req,res) -> {
			JsonObject jsonObject = new JsonObject();
			jsonObject.add("name", "biezhi");
			jsonObject.add("blog", "https://biezhi.me");
			res.json(jsonObject.toString());
		});
		
		blade.before("/.*", (req,res) -> {
			System.out.println("before");
		});
		
		blade.listen(9001).start();
	}
}

Run

git clone https://github.com/bladejava/hello.git

Import Project to your IDE. Run main method.

Console

2015-10-10 16:24:49,677 DEBUG [main] com.blade.route.impl.DefaultRouteMatcher | Add Route:GET:/
2015-10-10 16:24:49,732 DEBUG [main] com.blade.route.impl.DefaultRouteMatcher | Add Route:GET:/hello
2015-10-10 16:24:49.804:INFO::main: Logging initialized @340ms
2015-10-10 16:24:49.921:INFO:oejs.Server:main: jetty-9.3.4.v20151007
2015-10-10 16:24:49,987 INFO [main] com.blade.ioc.impl.DefaultContainer | register object:me.biezhi.hello.App=me.biezhi.hello.App@f5f2bb7
2015-10-10 16:24:49,987 INFO [main] com.blade.CoreFilter | blade init complete!
2015-10-10 16:24:49.990:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@25618e91{/,file:///C:/Users/renqi/AppData/Local/Temp/,AVAILABLE}
2015-10-10 16:24:50.027:INFO:oejs.ServerConnector:main: Started ServerConnector@668d9470{HTTP/1.1,[http/1.1]}{0.0.0.0:9001}
2015-10-10 16:24:50.028:INFO:oejs.Server:main: Started @566ms

2015-10-10 16:25:07,540 DEBUG [qtp193064360-17] com.blade.FilterHandler | Request : GET	/
2015-10-10 16:24:58,709 DEBUG [qtp193064360-15] com.blade.FilterHandler | Request : GET	/hello

Web

http://localhost:9001/

http://localhost:9001/hello

hello-1's People

Contributors

hellokaton avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.