Skip to content
Snippets Groups Projects
Commit 468d79f7 authored by Dave Welsh's avatar Dave Welsh
Browse files

Added front end files.

parent 88d416ff
No related branches found
No related tags found
No related merge requests found
from flask import Flask, render_template, url_for, flash, redirect
from flask import jsonify
from flask import request
import test_data_provider as provider
import requests
import urllib.request
import os
from werkzeug.utils import secure_filename
app = Flask(__name__)
UPLOAD_FOLDER = 'static/uploads/'
app.secret_key = "secret key"
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 * 1000 * 20 # 20 GB
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif', 'tif'])
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/')
def home():
return render_template('home.html')
@app.route('/', methods=['GET', "POST"])
def upload_image():
if 'file' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['file']
if file.filename == '':
flash('No image selected for uploading')
return redirect(request.url)
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)
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)
return redirect(url_for('static', filename='uploads/' + filename), code=301)
@app.route("/report/<int:report_id>")
def get_report(report_id) :
return jsonify(provider.get_report(report_id))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment