各种语言restful比较

Go风格:Martini
package main

import "github.com/go-martini/martini"

func main() {
  m := martini.Classic()
  m.Get("/", func() string {
    return "Hello world!"
  })
  m.Run()
}

Python风格:Flask
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()


Java风格:Spark
import static spark.Spark.*;

    public class HelloWorld {
        public static void main(String[] args) {
            get("/hello", (req, res) -> "Hello World");
        }
    }

Nodejs风格:Koa
var koa = require('koa');
var app = koa();
app.use(function *(){
  this.body = 'Hello World';
});
app.listen(3000);

Ruby风格:Sinatra
# myapp.rb
require 'sinatra'

get '/' do
  'Hello world!'
end


大同小异
其他推荐:
Python: Twisted
Golang: Gorilla Pat

ref:
https://medium.com/@tschundeee/express-vs-flask-vs-go-acc0879c2122
...

你可能感兴趣的:(Restful)