Last active
January 26, 2017 20:02
-
-
Save fxg42/55e968649261a37ac6ac to your computer and use it in GitHub Desktop.
Comparing Express, Phoenix, Rails, Flask, Grails and... PHP?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo json_encode(array('hello'=>'world!')); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask import jsonify | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return jsonify(hello="world!") | |
if __name__ == "__main__": | |
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloController < ApplicationController | |
def index | |
render json:{"hello"=>"world!"} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloController { | |
def index() { | |
render([ hello:"world!" ] as grails.converters.JSON) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var router = express.Router(); | |
router.get('/', function(req, res) { | |
res.json({hello:'world!'}); | |
}); | |
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule HelloPhoenix.PageController do | |
use Phoenix.Controller | |
alias Poison, as: JSON | |
plug :action | |
def index(conn, _params) do | |
json conn, JSON.encode!(%{hello: "world!"}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a note:
rails s
in the development environment runs a single-threaded server that has debugging tools enabled. It's not close to production performance or behavior.