import os from flask import ( Blueprint, flash, g, redirect, render_template, request, url_for ) from werkzeug.exceptions import abort from app.auth import login_required from app.db import get_db from werkzeug.utils import secure_filename ALLOWED_EXTENSIONS = {'md'} UPLOAD_FOLDER = os.getcwd() + '/app/uploads' bp = Blueprint('index', __name__) @bp.route('/') @login_required def index(): db = get_db() loginEvents = db.execute( 'SELECT *' ' FROM loginEvent' ' ORDER BY created DESC' ).fetchall() return render_template('index.html', loginEvents = loginEvents) def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS @bp.route('/upload', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] # If the user does not select a file, the browser submits an # empty file without a filename. if file.filename == '': flash('No selected file') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(UPLOAD_FOLDER, filename)) return redirect(url_for('index')) return ''' Upload new File

Upload new File

'''