ContactBridge

Log | Files | Refs | README

commit 1ae25b10ed89d25dad9abd2deee59e33a64d6db9
parent 3f053fe421591950b0beae868caeefafe6954532
Author: William Lindholm <william_lindholm@outlook.com>
Date:   Tue, 31 Oct 2023 23:51:56 +0100

Implemented page for viewing messages.

Diffstat:
MWebAPI/routes.py | 2+-
MWebInterface/__init__.py | 6++++--
MWebInterface/routes.py | 22++++++++++++++++++++--
RWebAPI/dbrepository.py -> dbrepository.py | 0
RWebInterface/template.html -> templates/home.html | 0
5 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/WebAPI/routes.py b/WebAPI/routes.py @@ -1,7 +1,7 @@ from . import api from flask_restx import Resource, fields -from .dbrepository import DatabaseRepository +from dbrepository import DatabaseRepository from .mailer import Mailer mailer = Mailer() diff --git a/WebInterface/__init__.py b/WebInterface/__init__.py @@ -1,3 +1,5 @@ from flask import Blueprint -web_interface = Blueprint('web_interface', __name__) -\ No newline at end of file +web_interface = Blueprint('web_interface', __name__) + +from . import routes +\ No newline at end of file diff --git a/WebInterface/routes.py b/WebInterface/routes.py @@ -1,6 +1,24 @@ from flask import render_template + +from dbrepository import DatabaseRepository from . import web_interface +db = DatabaseRepository() + @web_interface.route('/home') def home(): - return render_template('home.html') -\ No newline at end of file + messages = db.fetch_messages() + + formatted_messages = [ + { + "id": message[0], + "name": message[1], + "email": message[2], + "subject": message[3], + "message_content": message[4], + "timestamp": message[5] + } + for message in messages + ] + + return render_template('home.html', messages=formatted_messages) +\ No newline at end of file diff --git a/WebAPI/dbrepository.py b/dbrepository.py diff --git a/WebInterface/template.html b/templates/home.html