Skip to content
Snippets Groups Projects
Commit a50fb79e authored by dw927's avatar dw927
Browse files

Added reports page and intial custom css. Reports now display on their own page.

parent 5c8e9dd3
No related branches found
No related tags found
1 merge request!3Connected test_report_provider to fake_model. API now returns proper structure...
from flask import Flask, render_template, url_for, flash, redirect from flask import Flask, render_template, url_for, flash, redirect, request
from flask import request
import requests import requests
import urllib.request import urllib.request
import os import os
...@@ -8,7 +7,6 @@ from werkzeug.utils import secure_filename ...@@ -8,7 +7,6 @@ from werkzeug.utils import secure_filename
app = Flask(__name__) app = Flask(__name__)
UPLOAD_FOLDER = 'static/uploads/' UPLOAD_FOLDER = 'static/uploads/'
REPORTS_SERVICE_URL = 'http://127.0.0.1:5000' REPORTS_SERVICE_URL = 'http://127.0.0.1:5000'
...@@ -17,19 +15,30 @@ app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER ...@@ -17,19 +15,30 @@ 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']) ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif', 'tif'])
BASE_URL = 'dpath'
def allowed_file(filename): def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/')
@app.route(f'/{BASE_URL}/')
def home(): def home():
return render_template('home.html') return render_template('home.html')
@app.route('/term2')
@app.route(f'/{BASE_URL}/term2')
def term2(): def term2():
reports = requests.get(f'{REPORTS_SERVICE_URL}/dpath/report').json() reports = requests.get(f'{REPORTS_SERVICE_URL}/dpath/report').json()
return render_template('2ndTerm.html', reports=reports) 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"]) @app.route('/', methods=['GET', "POST"])
def upload_image(): def upload_image():
if 'file' not in request.files: if 'file' not in request.files:
...@@ -49,10 +58,12 @@ def upload_image(): ...@@ -49,10 +58,12 @@ def upload_image():
flash('Allowed image types are - png, jpg, jpeg, gif, tif') flash('Allowed image types are - png, jpg, jpeg, gif, tif')
return redirect(request.url) return redirect(request.url)
@app.route('/display/<filename>') @app.route('/display/<filename>')
def display_image(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) return redirect(url_for('static', filename='uploads/' + filename), code=301)
if __name__ == "__main__": if __name__ == "__main__":
app.run(debug=True) app.run(debug=True)
\ No newline at end of file
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
...@@ -3,16 +3,11 @@ ...@@ -3,16 +3,11 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Slide Analyzer</title> <title>Slide Analyzer</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" {% include 'includes/stylesload.html' %}
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
</head> </head>
{% include 'includes/navbar.html' %} {% include 'includes/navbar.html' %}
<div class="list-group">
{% include 'includes/reports.html' %}
</div>
<div class="progress w-50"> <div class="progress w-50">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" <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%"> aria-label="Animated striped example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<a class="navbar-brand" href="#">Digital Pathology</a> <a class="navbar-brand" href="#">Digital Pathology</a>
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#">Reports</a> <a class="nav-link" href="./reports">Reports</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#">New Report</a> <a class="nav-link" href="#">New Report</a>
......
{% block content %} {% block content %}
<h1>{% block title %} Reports {% endblock %}</h1> <h1>{% block title %} Reports {% endblock %}</h1>
<div class="list-group-item report"> <table class="report-table">
<th class="left">Id</th>
<th class="left">Status</th>
<th class="right">Run Date</th>
{% for report in reports %} {% for report in reports %}
<div class="d-flex w-100 justify-content-between"> <tr>
<h5 class="mb-1">{{ report.id }}</h5> <td class="left">{{ report.id }}</td>
<small>{{ report.report.runDate }}</small> <td class="left">Completed</td>
</div> <td class="right">{{ report.report.runDate }}</td>
</tr>
{% endfor %} {% endfor %}
</table>
{% endblock %} {% endblock %}
\ No newline at end of file
{% 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
<!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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment