diff --git a/front_end/dpath.py b/front_end/dpath.py index f71227d1f2f66f8f207e6340c3bcac16cb96d3b4..f546048b2975c80ab19cc5cb2443fab1f79d1982 100644 --- a/front_end/dpath.py +++ b/front_end/dpath.py @@ -1,5 +1,4 @@ -from flask import Flask, render_template, url_for, flash, redirect -from flask import request +from flask import Flask, render_template, url_for, flash, redirect, request import requests import urllib.request import os @@ -8,28 +7,38 @@ from werkzeug.utils import secure_filename app = Flask(__name__) - UPLOAD_FOLDER = 'static/uploads/' REPORTS_SERVICE_URL = 'http://127.0.0.1:5000' - + app.secret_key = "secret key" app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER -app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 * 1000 * 20 # 20 GB +app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 * 1000 * 20 # 20 GB ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif', 'tif']) - +BASE_URL = 'dpath' + + def allowed_file(filename): return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS -@app.route('/') + +@app.route(f'/{BASE_URL}/') def home(): return render_template('home.html') -@app.route('/term2') + +@app.route(f'/{BASE_URL}/term2') def term2(): reports = requests.get(f'{REPORTS_SERVICE_URL}/dpath/report').json() return render_template('2ndTerm.html', reports=reports) + +@app.route(f'/{BASE_URL}/reports') +def reports(): + reports = requests.get(f'{REPORTS_SERVICE_URL}/dpath/report').json() + return render_template('reports.html', reports=reports) + + @app.route('/', methods=['GET', "POST"]) def upload_image(): if 'file' not in request.files: @@ -42,17 +51,19 @@ def upload_image(): if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) - #print('upload_image filename: ' + filename) + # print('upload_image filename: ' + filename) flash('Image successfully uploaded.') return render_template('home.html', filename=filename) else: flash('Allowed image types are - png, jpg, jpeg, gif, tif') return redirect(request.url) + @app.route('/display/<filename>') def display_image(filename): - #print('display_image filename: ' + filename) + # print('display_image filename: ' + filename) return redirect(url_for('static', filename='uploads/' + filename), code=301) + if __name__ == "__main__": app.run(debug=True) \ No newline at end of file diff --git a/front_end/static/styles/style.css b/front_end/static/styles/style.css new file mode 100644 index 0000000000000000000000000000000000000000..5bc2f3b2c2a8ea0a247f0e569b0dc31717e6c002 --- /dev/null +++ b/front_end/static/styles/style.css @@ -0,0 +1,35 @@ +body { + width: 100%; +} + +.container { + width: 100%; + text-align: center; +} + +.report-table { + width: 90%; + padding: 20px; +} + +th { + padding: 5px; + background-color: lightskyblue; +} + +tr:hover { + background-color: lightgray; +} + +td { + padding-left: 5px; + padding-right: 5px; +} + +.left { + text-align: left; +} + +.right { + text-align: right; +} \ No newline at end of file diff --git a/front_end/templates/2ndTerm.html b/front_end/templates/2ndTerm.html index eec6821541638af65c64223ead5ecde07c9e0617..5c963d75c2d8b7d31289d3a7b9827e8d2c49b6f3 100644 --- a/front_end/templates/2ndTerm.html +++ b/front_end/templates/2ndTerm.html @@ -3,16 +3,11 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Slide Analyzer</title> - <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" - integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"> + {% include 'includes/stylesload.html' %} </head> {% include 'includes/navbar.html' %} -<div class="list-group"> - {% include 'includes/reports.html' %} -</div> - <div class="progress w-50"> <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-label="Animated striped example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"> diff --git a/front_end/templates/includes/navbar.html b/front_end/templates/includes/navbar.html index 1d58771782752cc86e9aa9f5bae7b01c1f897ce8..26c03b78ba13c25805be6dea9da533bc998799fe 100644 --- a/front_end/templates/includes/navbar.html +++ b/front_end/templates/includes/navbar.html @@ -2,7 +2,7 @@ <a class="navbar-brand" href="#">Digital Pathology</a> <ul class="navbar-nav mr-auto"> <li class="nav-item"> - <a class="nav-link" href="#">Reports</a> + <a class="nav-link" href="./reports">Reports</a> </li> <li class="nav-item"> <a class="nav-link" href="#">New Report</a> diff --git a/front_end/templates/includes/reports.html b/front_end/templates/includes/reports.html index 29b1eda1442b015f22efaf23bca6b6e25d3f88e7..00d5fbd3bdd0d3245cbd49effe568d927b1bc371 100644 --- a/front_end/templates/includes/reports.html +++ b/front_end/templates/includes/reports.html @@ -1,10 +1,16 @@ {% block content %} <h1>{% block title %} Reports {% endblock %}</h1> -<div class="list-group-item report"> - {% for report in reports %} - <div class="d-flex w-100 justify-content-between"> - <h5 class="mb-1">{{ report.id }}</h5> - <small>{{ report.report.runDate }}</small> - </div> - {% endfor %} -{% endblock %} \ No newline at end of file + <table class="report-table"> + <th class="left">Id</th> + <th class="left">Status</th> + <th class="right">Run Date</th> + {% for report in reports %} + <tr> + <td class="left">{{ report.id }}</td> + <td class="left">Completed</td> + <td class="right">{{ report.report.runDate }}</td> + </tr> + {% endfor %} + </table> + + {% endblock %} \ No newline at end of file diff --git a/front_end/templates/includes/stylesload.html b/front_end/templates/includes/stylesload.html new file mode 100644 index 0000000000000000000000000000000000000000..4356bf723dbd9827bdc0c89e0474a881a961c708 --- /dev/null +++ b/front_end/templates/includes/stylesload.html @@ -0,0 +1,5 @@ +{% block content %} +<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" + integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"> +<link href="{{ url_for('static', filename='styles/style.css') }}" rel="stylesheet"> +{% endblock %} \ No newline at end of file diff --git a/front_end/templates/reports.html b/front_end/templates/reports.html new file mode 100644 index 0000000000000000000000000000000000000000..b579b6b5d15bc5ede0e53864f887b7130ea004b1 --- /dev/null +++ b/front_end/templates/reports.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> + +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Reports</title> + {% include 'includes/stylesload.html' %} +</head> + +<body> + {% include 'includes/navbar.html' %} + <div class="container"> + {% include 'includes/reports.html' %} + </div> +</body> \ No newline at end of file