Note that there is no need for the conditional if you just want to serve this route (and there is no need for the conditional block at all if you're just defining view functions), and that this whole block exists once per project.
And that a Flask app is a proper WSGI application (as opposed to a self-running Sinatra handler which has to be quite significantly modified to be Rack-compatible)
As a result, the actual verbosity difference comes down to:
So, as usual, Python not having multiline anonymous functions: for this very case you could write
app.route('/')(
lambda: "Hello World!")
but that kind-of looks like shit and you're hosed if you want to add more stuff.
(one could argue that the Flask version lets you formally write docstrings which standard Python doc tools will understand)
(and if you're wondering, yes Flask could provide support for not needing to define an app or run it for this trivial example, leaving named functions as the only actual overhead over Sinatra. I don't think there's much value in it, but it wouldn't be very hard)
as opposed to a self-running Sinatra handler which has to be quite significantly modified to be Rack-compatible
Huh? Here's the `config.ru` that you need:
$: << File.dirname(__FILE__)
require 'app' #assuming app.rb
run Sinatra::Application
Note that I have no stake in the verbosity claims, as it's not something I particularly care about. But I wouldn't consider this a significant modification.
I guess saving a couple lines is nice, but flask is already so concise, I have no complaints about keystrokes. Plus, for a real app, I imagine the percent more lines would be smaller, though I don't know sinatra's syntax for other stuff.
And that a Flask app is a proper WSGI application (as opposed to a self-running Sinatra handler which has to be quite significantly modified to be Rack-compatible)
As a result, the actual verbosity difference comes down to:
versus So, as usual, Python not having multiline anonymous functions: for this very case you could write but that kind-of looks like shit and you're hosed if you want to add more stuff.(one could argue that the Flask version lets you formally write docstrings which standard Python doc tools will understand)
(and if you're wondering, yes Flask could provide support for not needing to define an app or run it for this trivial example, leaving named functions as the only actual overhead over Sinatra. I don't think there's much value in it, but it wouldn't be very hard)