Skip to content

Instantly share code, notes, and snippets.

@fxg42
Last active January 26, 2017 20:02
Show Gist options
  • Save fxg42/55e968649261a37ac6ac to your computer and use it in GitHub Desktop.
Save fxg42/55e968649261a37ac6ac to your computer and use it in GitHub Desktop.
Comparing Express, Phoenix, Rails, Flask, Grails and... PHP?
<?php
echo json_encode(array('hello'=>'world!'));
?>
from flask import Flask
from flask import jsonify
app = Flask(__name__)
@app.route("/")
def hello():
return jsonify(hello="world!")
if __name__ == "__main__":
app.run()
class HelloController < ApplicationController
def index
render json:{"hello"=>"world!"}
end
end
class HelloController {
def index() {
render([ hello:"world!" ] as grails.converters.JSON)
}
}
var express = require('express');
var router = express.Router();
router.get('/', function(req, res) {
res.json({hello:'world!'});
});
module.exports = router;
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
@RobinDaugherty
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment