I've seen a pattern in Flask (and Lithium) where a single view method corresponds to multiple HTTP verbs; example:
@app.route('/login', methods=['GET', 'POST'])
def login():
error = None
if request.method == 'POST':
if request.form['username'] != app.config['USERNAME']:
error = 'Invalid username'
elif request.form['password'] != app.config['PASSWORD']:
error = 'Invalid password'
else:
session['logged_in'] = True
flash('You were logged in')
return redirect(url_for('show_entries'))
return render_template('login.html', error=error)
I think this leads to bloated view methods that do more than one thing.
I was going to ask why this was the default pattern in Flask, but now I see that method-based views exist.
Still, why have non-method based views in the framework at all? Because not all client-server protocols talk through REST, and method-based views are inherently REST-flavored?