From 093e1d415d5f3e99e133cf327a76efbb327fa14f Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Mon, 27 Dec 2021 08:54:55 +0100 Subject: [PATCH] Refactor: use Flask class based views --- ereuse_devicehub/views.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py index 45002513..7cd92609 100644 --- a/ereuse_devicehub/views.py +++ b/ereuse_devicehub/views.py @@ -1,8 +1,15 @@ from flask import Blueprint, render_template +from flask.views import View + core = Blueprint('core', __name__) -@core.route('/profile/') -def user_profile(): - return render_template('ereuse_devicehub/user_profile.html') +class UserProfileView(View): + template_name = 'ereuse_devicehub/user_profile.html' + + def dispatch_request(self): + return render_template(self.template_name) + + +core.add_url_rule('/profile/', view_func=UserProfileView.as_view('user-profile'))